Package jmri.server.json
Class JsonConnection
java.lang.Object
jmri.jmris.JmriConnection
jmri.server.json.JsonConnection
Abstraction of DataOutputStream and WebSocket.Connection classes for JSON
clients.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final JsonServerPreferencesprotected final JsonSchemaServiceCache -
Constructor Summary
ConstructorsConstructorDescriptionJsonConnection(DataOutputStream output) JsonConnection(org.eclipse.jetty.websocket.api.Session connection) -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.ObjectMapperGet the ObjectMapper for this connection.voidsendMessage(com.fasterxml.jackson.databind.JsonNode message, int id) Send a JsonNode to the instantiated connection.voidsendMessage(com.fasterxml.jackson.databind.JsonNode message, JsonRequest request) Send a JsonNode to the instantiated connection.voidsetVersion(String version) Methods inherited from class jmri.jmris.JmriConnection
close, getDataOutputStream, getLocale, getSession, sendMessage, setLocale
-
Field Details
-
preferences
-
schemas
-
-
Constructor Details
-
JsonConnection
-
JsonConnection
-
-
Method Details
-
getObjectMapper
Get the ObjectMapper for this connection.- Returns:
- the ObjectMapper
-
sendMessage
public void sendMessage(@Nonnull com.fasterxml.jackson.databind.JsonNode message, @Nonnull JsonRequest request) throws IOException Send a JsonNode to the instantiated connection.This method throws an IOException so the server or servlet holding the connection open can respond to the exception.
If
JsonServerPreferences.getValidateServerMessages()istrue, a message is sent to the client that validation failed instead of the intended message.Overriding methods must ensure that
messageis only sent if validated.- Parameters:
message- the object or array to send as a messagerequest- the JSON request- Throws:
IOException- if unable to send the message
-
sendMessage
public void sendMessage(@Nonnull com.fasterxml.jackson.databind.JsonNode message, int id) throws IOException Send a JsonNode to the instantiated connection.This method throws an IOException so the server or servlet holding the connection open can respond to the exception.
If
JsonServerPreferences.getValidateServerMessages()istrue, a message is sent to the client that validation failed instead of the intended message.Overriding methods must ensure that
messageis only sent if validated.- Parameters:
message- the object or array to send as a messageid- the message id set by the client- Throws:
IOException- if unable to send the message
-
getVersion
-
setVersion
-