Package jmri.server.json
Class JsonClientHandler
- java.lang.Object
-
- jmri.server.json.JsonClientHandler
-
public class JsonClientHandler extends java.lang.Object
Handler for JSON messages from a TCP socket or WebSocket client.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHELLO_MSGWhen used as a parameter toonMessage(java.lang.String), will cause a "hello" message to be sent to the client.
-
Constructor Summary
Constructors Constructor Description JsonClientHandler(JsonConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.HashMap<java.lang.String,java.util.HashSet<JsonSocketService<?>>>getServices()voidonClose()voidonMessage(com.fasterxml.jackson.databind.JsonNode root)Process a JSON node and handle appropriately.voidonMessage(java.lang.String string)Process a JSON string and handle appropriately.
-
-
-
Field Detail
-
HELLO_MSG
public static final java.lang.String HELLO_MSG
When used as a parameter toonMessage(java.lang.String), will cause a "hello" message to be sent to the client.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JsonClientHandler
public JsonClientHandler(JsonConnection connection)
-
-
Method Detail
-
onClose
public void onClose()
-
onMessage
public void onMessage(java.lang.String string) throws java.io.IOException
Process a JSON string and handle appropriately.See
jmri.server.jsonfor expected JSON objects.- Parameters:
string- the message- Throws:
java.io.IOException- if communications with the client is broken- See Also:
onMessage(JsonNode)
-
onMessage
public void onMessage(com.fasterxml.jackson.databind.JsonNode root) throws java.io.IOException
Process a JSON node and handle appropriately.See
jmri.server.jsonfor expected JSON objects.- Parameters:
root- the JSON node.- Throws:
java.io.IOException- if communications with the client is broken- See Also:
onMessage(java.lang.String)
-
getServices
protected java.util.HashMap<java.lang.String,java.util.HashSet<JsonSocketService<?>>> getServices()
-
-