Class MessageProtocolDispatcher

java.lang.Object
com.inductiveautomation.perspective.gateway.session.MessageProtocolDispatcher
Direct Known Subclasses:
PageModel.Handlers

public class MessageProtocolDispatcher extends Object
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 Details

    • handlers

      protected final Map<String,com.inductiveautomation.perspective.gateway.session.MessageProtocolDispatcher.MessageHandler> handlers
  • Constructor Details

    • MessageProtocolDispatcher

      public MessageProtocolDispatcher(com.inductiveautomation.ignition.common.gson.Gson gson, LoggerEx log)
  • Method Details

    • receive

      public void receive(MessageChannel channel, String protocol, Reader payload)
    • register

      public <T> void register(String protocol, BiConsumer<MessageChannel,T> handler, Class<T> clazz)
    • handles

      public boolean handles(String protocol)
    • onFatalError

      protected void onFatalError(MessageChannel channel, String message)
    • onFatalError

      protected void onFatalError(MessageChannel channel, String message, Throwable t)
    • 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

      public void trySend(MessageChannel channel, String protocol, Object payload)
      Handy wrapper around MessageChannel.send that logs a warning upon failure.
      Parameters:
      payload - An object that will be gson-serialized automatically.
    • trySendInternal

      public void trySendInternal(MessageChannel channel, String protocol, String payload)