Package jmri.server.json.power
Class JsonPowerSocketService
- java.lang.Object
-
- jmri.server.json.JsonSocketService<JsonPowerHttpService>
-
- jmri.server.json.power.JsonPowerSocketService
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
public class JsonPowerSocketService extends JsonSocketService<JsonPowerHttpService> implements java.beans.PropertyChangeListener
-
-
Field Summary
-
Fields inherited from class jmri.server.json.JsonSocketService
connection, service
-
-
Constructor Summary
Constructors Modifier Constructor Description JsonPowerSocketService(JsonConnection connection)
protected
JsonPowerSocketService(JsonConnection connection, JsonPowerHttpService service)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onClose()
Perform any teardown required when closing a connection.void
onList(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)
Handle a request for a list of objects.void
onMessage(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)
Handle an inbound message.void
propertyChange(java.beans.PropertyChangeEvent evt)
-
Methods inherited from class jmri.server.json.JsonSocketService
getConnection, getHttpService, getLocale, getVersion
-
-
-
-
Constructor Detail
-
JsonPowerSocketService
public JsonPowerSocketService(JsonConnection connection)
-
JsonPowerSocketService
protected JsonPowerSocketService(JsonConnection connection, JsonPowerHttpService service)
-
-
Method Detail
-
onMessage
public void onMessage(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws java.io.IOException, JmriException, JsonException
Description copied from class:JsonSocketService
Handle an inbound message.- Specified by:
onMessage
in classJsonSocketService<JsonPowerHttpService>
- Parameters:
type
- The service type; if the implementing service responds to multiple types, it will need to use this to handle data correctlydata
- JSON data; the contents of this will depend on the implementing servicerequest
- The JSON request- Throws:
java.io.IOException
- Thrown if the service cannot send a response; this will cause the JSON Server to close its connection to the client if openJmriException
- Thrown if the request cannot be handled; throwing this will cause the JSON Server to pass a 500 UnsupportedOperation message to the clientJsonException
- Thrown if the service needs to pass an error message back to the client
-
onList
public void onList(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException, java.io.IOException
Description copied from class:JsonSocketService
Handle a request for a list of objects. Note that this should not create listeners for items in the list, but should only create listeners for the object providing the list, if applicable.- Specified by:
onList
in classJsonSocketService<JsonPowerHttpService>
- Parameters:
type
- The service type; if the implementing service responds to multiple types, it will need to use this to handle data correctlydata
- JSON data; the contents of this will depend on the implementing servicerequest
- The JSON request- Throws:
JsonException
- If the service needs to pass an error message back to the client; implementing services may throw a JsonException with code 400 and the localized message "UnlistableService" to indicate thattype
should not be listedjava.io.IOException
- Thrown if the service cannot send a response; this will cause the JSON Server to close its connection to the client if open
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
onClose
public void onClose()
Description copied from class:JsonSocketService
Perform any teardown required when closing a connection.- Specified by:
onClose
in classJsonSocketService<JsonPowerHttpService>
-
-