users@grizzly.java.net

Implementing a custom protocol with grizzly

From: John Romanicz <romanicz_at_conclude.de>
Date: Thu, 3 Jan 2008 15:47:46 +0100

 

Hello Dear Grizzly Team,

 

maybe you could give me some hints to get me started:

 

Lets say I have a custom Protocol which clients send over TCP/IP to
Grizzly server :

 

<magic number> [integer]
<msg length> [integer]
<bytes> [Serialized object]

 

  

  I guess I need to write a com.sun.grizzly.ProtocolFilter which parses
the protocol (probably a State machine)

  and add it to the Grizzly Protocolchain.

  

  I suppose the ByteBuffer which Grizzly passes to the ProtocolFilter
has a "fixed byte limit".

 

  So when a Client sends a message bigger than the "fixed byte limit" I
need to make sure the same ProtocolFilter gets recalled.

  

  How do I make sure that big messages use the same ProtocolFilter
instance?

 

  On the other hand of course how do I make sure that different calling
clients have their own ProtocolFilter instances?

  

 

 Many Greetings

 John