|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.streamhub.api.JsonPayload
public class JsonPayload
JsonPayload sends its message as a JSON string. Every message has at least one field 'topic' representing the topic that this message concerns.
Use the following to access the topic of a JsonPayload:
Payload payload = new JsonPayload("GOOG");
String topic = payload.getFields().get("topic");
| Constructor Summary | |
|---|---|
JsonPayload(String topic)
Creates a new JsonPayload with topic. |
|
| 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. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JsonPayload(String topic)
topic - the topic this payload will be sent with| Method Detail |
|---|
public void addField(String key,
String value)
Payload
addField in interface Payloadkey - the key of the message - must be uniquevalue - the value of the messagepublic Map<String,String> getFields()
Payload
getFields in interface Payloadpublic byte[] toCometBytes()
Payload
This method should not be used to send a payload,
use NIOServer.publish(String, Payload) or
Client.send(String, Payload) instead.
toCometBytes in interface Payloadpublic void timestamp()
PayloadSystem.currentTimeMillis().
timestamp in interface PayloadPayload.toggleTimestamping(boolean)public void toggleTimestamping(boolean onOrOff)
Payload
toggleTimestamping in interface PayloadonOrOff - A boolean representing whether to turn on timestamping
or not. Use true to enable it, and
false to disable it.Payload.timestamp()public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||