users@grizzly.java.net

Ping/Pong mechanism in Grizzly 2.1.8 WebSocket API

From: <justphilmusic_at_googlemail.com>
Date: Sat, 7 Jan 2012 23:18:55 +0000 (GMT)

Hello everybody!


I've started to play around with Grizzly's WebSocket API and right now
I'm about to build a small WebSocket based game.

In order to maintain the connection between my server and the clients
and to discover (mobile) network problems I would like to use a
ping/pong mechanism since it is part of the WebSocket specification.
(according to
http://dev.w3.org/html5/websockets/#ping-and-pong-frames).

By studying Grizzly's WebSocket related API docs I've discovered
callback methods like onPing() and onPong() in the WebSocketApplication
class. Consequently, I assumed that the WebSocket engine automatically
performs ping/pong cycles between the connected clients and
correspondingly invokes these callback methods, but I think I was
wrong. I cannot get them to work in my own WebSocketApplication
subclass.

To cut a long story short, would somebody be so kind and provide a
little example or some hints on how to get this feature to work?

Thanks in advance + have a nice weekend! :-)
Phil