- All Implemented Interfaces:
- MessageParsingStrategy
public class AwidMessageParsingStrategy
extends java.lang.Object
implements MessageParsingStrategy
The message parsing strategy for an Awid. The purpose of this class is to
decide when a stream of bytes forms a logical Awid message. It works like
this: the isMessage method is called each time a byte is read from the
socket. If the collected bytes forms a complete message, it should reset
itself and return them. If they do not, it should return null.
It follows this algorithm: Read the first byte. If it is a x00 or xFF, the
the incoming message is an acknowledgement for a previously sent command. If
not, read the second byte. If both the first byte and the second byte are a
'i', then the message is a welcome message, and we continue reading until we
see the string "MODULE", which is the end of the message. Otherwise, the
first byte is the number of bytes in the message, and we need to continue
reading until we see that number of bytes
- Author:
- Kyle Neumeier - kyle@pramari.com