Package jmri.server.json
Class JsonSocketService<H extends JsonHttpService>
- java.lang.Object
- 
- jmri.server.json.JsonSocketService<H>
 
- 
- Type Parameters:
- H- The supporting JsonHttpService implementing class
 - Direct Known Subclasses:
- JsonAudioIconSocketService,- JsonConsistSocketService,- JsonLayoutBlockSocketService,- JsonLogixNGIconSocketService,- JsonMessageSocketService,- JsonNamedBeanSocketService,- JsonOperationsSocketService,- JsonPowerSocketService,- JsonRosterSocketService,- JsonSchemaSocketService,- JsonSignalHeadSocketService,- JsonThrottleSocketService,- JsonTimeSocketService,- JsonUtilSocketService
 
 public abstract class JsonSocketService<H extends JsonHttpService> extends java.lang.Object Interface for JSON Services provided over TCP Sockets or WebSockets.
- 
- 
Field SummaryFields Modifier and Type Field Description protected JsonConnectionconnectionprotected Hservice
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedJsonSocketService(JsonConnection connection, H service)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description JsonConnectiongetConnection()Get the connection to the client.HgetHttpService()Get the supportingJsonHttpService.protected java.util.LocalegetLocale()Get the in-use localeprotected java.lang.StringgetVersion()Get the JSON protocol versionabstract voidonClose()Perform any teardown required when closing a connection.abstract voidonList(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)Handle a request for a list of objects.abstract voidonMessage(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request)Handle an inbound message.
 
- 
- 
- 
Field Detail- 
connectionprotected final JsonConnection connection 
 - 
serviceprotected final H extends JsonHttpService service 
 
- 
 - 
Constructor Detail- 
JsonSocketServiceprotected JsonSocketService(@Nonnull JsonConnection connection, @Nonnull H service) 
 
- 
 - 
Method Detail- 
onMessagepublic abstract void onMessage(@Nonnull java.lang.String type, @Nonnull com.fasterxml.jackson.databind.JsonNode data, @Nonnull JsonRequest request) throws java.io.IOException, JmriException, JsonException Handle an inbound message.- Parameters:
- type- The service type; if the implementing service responds to multiple types, it will need to use this to handle data correctly
- data- JSON data; the contents of this will depend on the implementing service
- request- 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 open
- JmriException- Thrown if the request cannot be handled; throwing this will cause the JSON Server to pass a 500 UnsupportedOperation message to the client
- JsonException- Thrown if the service needs to pass an error message back to the client
 
 - 
onListpublic abstract void onList(@Nonnull java.lang.String type, @Nonnull com.fasterxml.jackson.databind.JsonNode data, @Nonnull JsonRequest request) throws java.io.IOException, JmriException, JsonException 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.- Parameters:
- type- The service type; if the implementing service responds to multiple types, it will need to use this to handle data correctly
- data- JSON data; the contents of this will depend on the implementing service
- request- 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 open
- JmriException- Thrown if the request cannot be handled; throwing this will cause the JSON Server to pass a 500 UnsupportedOperation message to the client
- 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 that- typeshould not be listed
 
 - 
onClosepublic abstract void onClose() Perform any teardown required when closing a connection.
 - 
getConnection@Nonnull public final JsonConnection getConnection() Get the connection to the client.- Returns:
- the connection
 
 - 
getHttpService@Nonnull public final H getHttpService() Get the supportingJsonHttpService.- Returns:
- the supporting service
 
 - 
getLocale@Nonnull protected final java.util.Locale getLocale() Get the in-use locale- Returns:
- the locale
 
 - 
getVersionprotected final java.lang.String getVersion() Get the JSON protocol version- Returns:
- the version
 
 
- 
 
-