Package jmri.server.json.loconet
Class JsonLoconetSlotUsageSocketService
java.lang.Object
jmri.server.json.JsonSocketService<JsonLoconetSlotUsageHttpService>
jmri.server.json.loconet.JsonLoconetSlotUsageSocketService
public class JsonLoconetSlotUsageSocketService
extends JsonSocketService<JsonLoconetSlotUsageHttpService>
Minimal WebSocket handling for "loconetSlotUsage" -- a one-shot query,
not something a client subscribes to, so every message (GET or LIST)
is answered the same way as the HTTP GET, with no held subscription
state to release on close.
A real, minimal implementation is used here rather than a null socket
service, since JsonClientHandler registers whatever getSocketService()
returns into every type's dispatch set unconditionally -- a null entry
there would NPE the first time a WebSocket client sent this type.
-
Field Summary
Fields inherited from class jmri.server.json.JsonSocketService
connection, service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonClose()Perform any teardown required when closing a connection.voidonList(String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) Handle a request for a list of objects.voidonMessage(String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) Handle an inbound message.Methods inherited from class jmri.server.json.JsonSocketService
getConnection, getHttpService, getLocale, getVersion
-
Constructor Details
-
JsonLoconetSlotUsageSocketService
-
-
Method Details
-
onMessage
public void onMessage(String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws IOException, JmriException, JsonException Description copied from class:JsonSocketServiceHandle an inbound message.- Specified by:
onMessagein classJsonSocketService<JsonLoconetSlotUsageHttpService>- 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:
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(String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws IOException, JmriException, JsonException Description copied from class:JsonSocketServiceHandle 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:
onListin classJsonSocketService<JsonLoconetSlotUsageHttpService>- 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:
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- 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 thattypeshould not be listed
-
onClose
Description copied from class:JsonSocketServicePerform any teardown required when closing a connection.- Specified by:
onClosein classJsonSocketService<JsonLoconetSlotUsageHttpService>
-