NetPlay is my attempt at making a pluggable messaging framework for Java. Messages are passed along Sockets (or, possibly any two-way stream implementation) as a byte stream. The actual message itself is a plug-in which knows how to transform itself into and from a String (read and written to a byte stream). This allows speed advantages over the Object Stream in Java's serialization.
Messages are passed along the streams with a header which indicates some minimal information: a 32-bit unique identifier for the message class (the CRC-32 of the message class name), and the message length. All this is passed and computed under the hood.
Message classes must extend the NetMessage class. This base class is automatically set up to register the message class to the message factory, which is in charge of discovering message classes from message headers.
The message factory has the ability to pool message instances, reducing the impact of the Garbage Collector (GC) on performance.
Classes and methods are pre-setup to support branching a thread to listen to a socket, and for binding client sockets to a server socket.
In addition, a state-machine is offered in a sub-package, which allows for fast-and-easy state transitions based on the messages received.
In its current state, the client / server divide and class heirarchy is a little convoluted. After deeper inspection and thought, it is imagined that this design knot will untie itself.
The source code can be requested from the author (onewith1@flash.net). If there are enough requests, I'll pass it on to the CVS server.
-- MattAlbrecht - 17 Nov 1999