Class SimpleSendWithQueue

  • All Implemented Interfaces:
    FlowContextHandler, com.pusher.java_websocket.WebSocket, com.pusher.java_websocket.WebSocketListener, Runnable

    public class SimpleSendWithQueue
    extends com.pusher.java_websocket.client.WebSocketClient
    implements FlowContextHandler
    Simple client for sending messages, forwards the received response in the specified queue.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface com.pusher.java_websocket.WebSocket

        com.pusher.java_websocket.WebSocket.READYSTATE, com.pusher.java_websocket.WebSocket.Role
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Actor m_FlowContext
      the flow context.
      protected Logger m_Logger
      for logging purposes.
      protected StorageName m_Queue
      the queue to use.
      • Fields inherited from class com.pusher.java_websocket.client.WebSocketClient

        uri
      • Fields inherited from interface com.pusher.java_websocket.WebSocket

        DEFAULT_PORT, DEFAULT_WSS_PORT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Actor getFlowContext()
      Returns the flow context, if any.
      protected Logger getLogger()
      Returns the logger instance to use.
      void onClose​(int code, String reason, boolean remote)
      On closing the connection.
      void onError​(Exception ex)
      In case of an error.
      void onMessage​(String message)
      When receiving a message.
      void onOpen​(com.pusher.java_websocket.handshake.ServerHandshake handshakedata)
      On opening the connection.
      void setFlowContext​(Actor value)
      Sets the flow context.
      • Methods inherited from class com.pusher.java_websocket.client.WebSocketClient

        close, close, close, closeBlocking, closeConnection, connect, connectBlocking, getConnection, getDraft, getLocalSocketAddress, getLocalSocketAddress, getReadyState, getRemoteSocketAddress, getRemoteSocketAddress, getResourceDescriptor, getURI, hasBufferedData, isClosed, isClosing, isConnecting, isFlushAndClose, isOpen, onCloseInitiated, onClosing, onFragment, onMessage, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketMessage, onWebsocketMessage, onWebsocketMessageFragment, onWebsocketOpen, onWriteDemand, run, send, send, send, sendFragmentedFrame, sendFrame, setProxy, setSocket
      • Methods inherited from class com.pusher.java_websocket.WebSocketAdapter

        getFlashPolicy, onWebsocketHandshakeReceivedAsClient, onWebsocketHandshakeReceivedAsServer, onWebsocketHandshakeSentAsClient, onWebsocketPing, onWebsocketPong
    • Field Detail

      • m_Logger

        protected Logger m_Logger
        for logging purposes.
      • m_FlowContext

        protected Actor m_FlowContext
        the flow context.
      • m_Queue

        protected StorageName m_Queue
        the queue to use.
    • Constructor Detail

      • SimpleSendWithQueue

        public SimpleSendWithQueue​(URI serverURI,
                                   Logger logger,
                                   StorageName queue)
        Initializes the client with the specified URI.
        Parameters:
        serverURI - the server to use
        logger - the logger to use
    • Method Detail

      • getFlowContext

        public Actor getFlowContext()
        Returns the flow context, if any.
        Specified by:
        getFlowContext in interface FlowContextHandler
        Returns:
        the actor, null if none available
      • getLogger

        protected Logger getLogger()
        Returns the logger instance to use.
        Returns:
        the logger
      • onOpen

        public void onOpen​(com.pusher.java_websocket.handshake.ServerHandshake handshakedata)
        On opening the connection.
        Specified by:
        onOpen in class com.pusher.java_websocket.client.WebSocketClient
        Parameters:
        handshakedata - the handshake
      • onMessage

        public void onMessage​(String message)
        When receiving a message.
        Specified by:
        onMessage in class com.pusher.java_websocket.client.WebSocketClient
        Parameters:
        message - the message
      • onClose

        public void onClose​(int code,
                            String reason,
                            boolean remote)
        On closing the connection.
        Specified by:
        onClose in class com.pusher.java_websocket.client.WebSocketClient
        Parameters:
        code - the code
        reason - the reason
        remote - whether remote
      • onError

        public void onError​(Exception ex)
        In case of an error.
        Specified by:
        onError in class com.pusher.java_websocket.client.WebSocketClient
        Parameters:
        ex - the exception