|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface MessageFactory
A factory for creating Gnutella messages.
MessageFactory delegates the parsing of specific messages to a MessageParser.
MessageParsers can be installed using
setParser(byte, com.limegroup.gnutella.messages.MessageFactory.MessageParser).
When reading a message from a stream, various optional parameters can be
provided. In all cases, a Message.Network is required to know which Network
the Message was read from. Optional parameters are softMax,
which can be used to limit the maximum number of hops a message should
travel, headerBuf which can be used as an optimization to
reduce byte[] allocations, and addr which can be used to know
what host this message was read from.
| Nested Class Summary | |
|---|---|
static interface |
MessageFactory.MessageParser
The interface for custom MessageParser(s) |
| Method Summary | |
|---|---|
Message |
createMessage(byte[] header,
byte[] payload,
Message.Network network,
byte softMax,
SocketAddress addr)
Creates a message based on the header & payload. |
MessageFactory.MessageParser |
getParser(byte functionId)
Returns a MessageParser for the provided functionId or null if no such MessageParser is registered. |
Message |
read(InputStream in,
Message.Network network)
|
Message |
read(InputStream in,
Message.Network network,
byte softMax)
|
Message |
read(InputStream in,
Message.Network network,
byte[] headerBuf,
byte softMax)
|
Message |
read(InputStream in,
Message.Network network,
byte[] headerBuf,
byte softMax,
SocketAddress addr)
|
Message |
read(InputStream in,
Message.Network network,
byte[] headerBuf,
SocketAddress addr)
Reads a message using the specified buffer & network and the default soft max. |
void |
setParser(byte functionId,
MessageFactory.MessageParser parser)
Registers a MessageParser under the provided functionId. |
| Method Detail |
|---|
void setParser(byte functionId,
MessageFactory.MessageParser parser)
functionId - the ID of the function (MessageParser)parser - the MessageParserMessageFactory.MessageParser getParser(byte functionId)
Message read(InputStream in,
Message.Network network,
byte softMax)
throws BadPacketException,
IOException
network - the network the message was read from.
BadPacketException
IOException
Message read(InputStream in,
Message.Network network)
throws BadPacketException,
IOException
BadPacketException
IOException
Message read(InputStream in,
Message.Network network,
byte[] headerBuf,
byte softMax)
throws BadPacketException,
IOException
network - the network the message was read from.
BadPacketException
IOException
Message read(InputStream in,
Message.Network network,
byte[] headerBuf,
SocketAddress addr)
throws BadPacketException,
IOException
BadPacketException
IOException
Message read(InputStream in,
Message.Network network,
byte[] headerBuf,
byte softMax,
SocketAddress addr)
throws BadPacketException,
IOException
network - the network this was received from.
BadPacketException
IOException
Message createMessage(byte[] header,
byte[] payload,
Message.Network network,
byte softMax,
SocketAddress addr)
throws BadPacketException,
IOException
BadPacketException
IOException
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||