|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Payload
A Payload represents a message which is to be
sent over the wire to a client or has been received from a client.
A Payload must implement toCometBytes(), #toString()
and have a client capable of decoding it.
The recommended implementation of Payload is JsonPayload which is supported out of the box in all StreamHub clients.
JsonPayload| Method Summary | |
|---|---|
void |
addField(String key,
String value)
Adds a field to the message with the key and value. |
Map<String,String> |
getFields()
Returns a map of every single field added to this message |
void |
timestamp()
If timestamping is enabled, adds a field named 'timestamp' to the Payload with a value of System.currentTimeMillis(). |
byte[] |
toCometBytes()
Returns a byte array representing the bytes ready to be sent over the wire to a Comet client. |
void |
toggleTimestamping(boolean onOrOff)
Toggles timestamping on or off. |
| Method Detail |
|---|
void addField(String key,
String value)
key - the key of the message - must be uniquevalue - the value of the messageMap<String,String> getFields()
byte[] toCometBytes()
This method should not be used to send a payload,
use NIOServer.publish(String, Payload) or
Client.send(String, Payload) instead.
void toggleTimestamping(boolean onOrOff)
onOrOff - A boolean representing whether to turn on timestamping
or not. Use true to enable it, and
false to disable it.timestamp()void timestamp()
System.currentTimeMillis().
toggleTimestamping(boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||