Class WebSocketConnectionServer
- java.lang.Object
 - 
- jadex.platform.service.message.websockettransport.AWebsocketConnection
 - 
- jadex.platform.service.message.websockettransport.WebSocketConnectionServer
 
 
 
- 
- All Implemented Interfaces:
 IWebSocketConnection
public class WebSocketConnectionServer extends AWebsocketConnection
Server-side websocket implemented using nanohttpd. 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected java.net.SocketsocketThe low-level socket.protected fi.iki.elonen.NanoWSD.WebSocketwebsocketThe web socket.- 
Fields inherited from class jadex.platform.service.message.websockettransport.AWebsocketConnection
bytesreceived, handler, hasheader, header, maxmsgsize, NULL_MSG_COMMAND, pojoagent 
 - 
 
- 
Constructor Summary
Constructors Constructor Description WebSocketConnectionServer(fi.iki.elonen.NanoHTTPD.IHTTPSession handshakerequest, ITransportHandler<IWebSocketConnection> handlr, java.net.Socket acceptsocket)Creates the websocket. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the connection (ignored if already closed).voidforceClose()Forcibly closes the connection (ignored if already closed).fi.iki.elonen.NanoWSD.WebSocketgetWebSocket()Returns the raw server web socket.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 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
WebSocketConnectionServer
public WebSocketConnectionServer(fi.iki.elonen.NanoHTTPD.IHTTPSession handshakerequest, ITransportHandler<IWebSocketConnection> handlr, java.net.Socket acceptsocket)Creates the websocket. 
 - 
 
- 
Method Detail
- 
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). 
- 
getWebSocket
public fi.iki.elonen.NanoWSD.WebSocket getWebSocket()
Returns the raw server web socket.- Returns:
 - The raw server web socket.
 
 
- 
sendAsFrames
protected void sendAsFrames(byte[] data) throws java.io.IOExceptionFragment and send data as websocket frames.- Parameters:
 data- The data.- Throws:
 java.io.IOException- On communication failure.
 
 - 
 
 -