Package adams.flow.websocket.client
Class SimpleSendWithQueue
- java.lang.Object
-
- com.pusher.java_websocket.WebSocketAdapter
-
- com.pusher.java_websocket.client.WebSocketClient
-
- adams.flow.websocket.client.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)
-
-
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.
-
Constructor Summary
Constructors Constructor Description SimpleSendWithQueue(URI serverURI, Logger logger, StorageName queue)
Initializes the client with the specified URI.
-
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
-
-
-
-
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 uselogger
- the logger to use
-
-
Method Detail
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context.- Specified by:
setFlowContext
in interfaceFlowContextHandler
- Parameters:
value
- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContext
in interfaceFlowContextHandler
- 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 classcom.pusher.java_websocket.client.WebSocketClient
- Parameters:
handshakedata
- the handshake
-
onMessage
public void onMessage(String message)
When receiving a message.- Specified by:
onMessage
in classcom.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 classcom.pusher.java_websocket.client.WebSocketClient
- Parameters:
code
- the codereason
- the reasonremote
- whether remote
-
onError
public void onError(Exception ex)
In case of an error.- Specified by:
onError
in classcom.pusher.java_websocket.client.WebSocketClient
- Parameters:
ex
- the exception
-
-