Class MessageProtocolDispatcher
java.lang.Object
com.inductiveautomation.perspective.gateway.session.MessageProtocolDispatcher
- Direct Known Subclasses:
PageModel.Handlers
Handles some boilerplate for classes that can handle receiving messages from a websocket channel. Basically
just a fancy wrapper around a map of protocol handling messages.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMessageProtocolDispatcher
(com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log) -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected void
onFatalError
(MessageChannel channel, String message) protected void
onFatalError
(MessageChannel channel, String message, Throwable t) void
receive
(MessageChannel channel, String protocol, Reader payload) <T> void
register
(String protocol, BiConsumer<MessageChannel, T> handler, Class<T> clazz) void
trySend
(MessageChannel channel, String protocol, com.inductiveautomation.ignition.common.gson.JsonObject payload) Handy wrapper around MessageChannel.send that logs a warning upon failure.void
trySend
(MessageChannel channel, String protocol, Object payload) Handy wrapper around MessageChannel.send that logs a warning upon failure.void
trySendInternal
(MessageChannel channel, String protocol, String payload)
-
Field Details
-
handlers
-
-
Constructor Details
-
MessageProtocolDispatcher
public MessageProtocolDispatcher(com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log)
-
-
Method Details
-
receive
-
register
-
handles
-
onFatalError
-
onFatalError
-
trySend
public void trySend(MessageChannel channel, String protocol, com.inductiveautomation.ignition.common.gson.JsonObject payload) Handy wrapper around MessageChannel.send that logs a warning upon failure. -
trySend
Handy wrapper around MessageChannel.send that logs a warning upon failure.- Parameters:
payload
- An object that will be gson-serialized automatically.
-
trySendInternal
-