Class WebSocketConnectionClient
- java.lang.Object
-
- jadex.platform.service.message.websockettransport.AWebsocketConnection
-
- jadex.platform.service.message.websockettransport.WebSocketConnectionClient
-
- All Implemented Interfaces:
IWebSocketConnection
public class WebSocketConnectionClient extends AWebsocketConnection
Client-side websocket connection.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringaddressThe connection address.protected JadexExecutorServiceAdapterexecserviceAccess to daemon thread pool for WS APIprotected com.neovisionaries.ws.client.WebSocketwebsocketThe websocket.-
Fields inherited from class jadex.platform.service.message.websockettransport.AWebsocketConnection
bytesreceived, handler, hasheader, header, maxmsgsize, NULL_MSG_COMMAND, pojoagent
-
-
Constructor Summary
Constructors Constructor Description WebSocketConnectionClient(java.lang.String address, IComponentIdentifier target, ITransportHandler<IWebSocketConnection> handler)Creates the connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the connection (ignored if already closed).IFuture<IWebSocketConnection>connect()Establishes the connection.voidforceClose()Forcibly closes the connection (ignored if already closed).protected voidsendAsFrames(byte[] data)Fragment and send data as websocket frames.IFuture<java.lang.Integer>sendMessage(byte[] header, byte[] body)Send bytes using the connection.-
Methods inherited from class jadex.platform.service.message.websockettransport.AWebsocketConnection
handleMessagePayload
-
-
-
-
Field Detail
-
address
protected java.lang.String address
The connection address.
-
websocket
protected com.neovisionaries.ws.client.WebSocket websocket
The websocket.
-
execservice
protected JadexExecutorServiceAdapter execservice
Access to daemon thread pool for WS API
-
-
Constructor Detail
-
WebSocketConnectionClient
public WebSocketConnectionClient(java.lang.String address, IComponentIdentifier target, ITransportHandler<IWebSocketConnection> handler)Creates the connection.- Parameters:
address- Target address.target- Target platform.
-
-
Method Detail
-
connect
public IFuture<IWebSocketConnection> connect()
Establishes the connection.- Returns:
- This object when done, exception on connection error.
-
sendMessage
public IFuture<java.lang.Integer> sendMessage(byte[] header, byte[] body)
Send bytes using the connection.- Parameters:
header- The message header.body- The message body.- Returns:
- A future indicating success.
-
close
public void close()
Closes the connection (ignored if already closed).
-
forceClose
public void forceClose()
Forcibly closes the connection (ignored if already closed).
-
sendAsFrames
protected void sendAsFrames(byte[] data)
Fragment and send data as websocket frames.- Parameters:
data- The data.fut- The future.
-
-