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 Actorm_FlowContextthe flow context.protected Loggerm_Loggerfor logging purposes.protected StorageNamem_Queuethe 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 ActorgetFlowContext()Returns the flow context, if any.protected LoggergetLogger()Returns the logger instance to use.voidonClose(int code, String reason, boolean remote)On closing the connection.voidonError(Exception ex)In case of an error.voidonMessage(String message)When receiving a message.voidonOpen(com.pusher.java_websocket.handshake.ServerHandshake handshakedata)On opening the connection.voidsetFlowContext(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:
setFlowContextin interfaceFlowContextHandler- Parameters:
value- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin 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:
onOpenin classcom.pusher.java_websocket.client.WebSocketClient- Parameters:
handshakedata- the handshake
-
onMessage
public void onMessage(String message)
When receiving a message.- Specified by:
onMessagein 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:
onClosein 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:
onErrorin classcom.pusher.java_websocket.client.WebSocketClient- Parameters:
ex- the exception
-
-