Package com.basiscomponents.comm
Class WsServer
- java.lang.Object
-
- org.java_websocket.WebSocketAdapter
-
- org.java_websocket.AbstractWebSocket
-
- org.java_websocket.server.WebSocketServer
-
- com.basiscomponents.comm.WsServer
-
- All Implemented Interfaces:
Runnable,WebSocketListener
public class WsServer extends WebSocketServer
A simple WebSocketServer implementation. Keeps track of a "chatroom".
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.java_websocket.server.WebSocketServer
WebSocketServer.WebSocketWorker
-
-
Field Summary
Fields Modifier and Type Field Description static BooleanDEBUG-
Fields inherited from class org.java_websocket.server.WebSocketServer
decoders, DECODERS
-
-
Constructor Summary
Constructors Constructor Description WsServer(int port)WsServer(InetSocketAddress address)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ObjectgetInstance(com.basis.bbj.proxies.BBjAPI api, int port)voidonClose(WebSocket conn, int code, String reason, boolean remote)Called after the websocket connection has been closed.voidonError(WebSocket conn, Exception ex)Called when errors occurs.voidonMessage(WebSocket conn, String message)Callback for string messages received from the remote hostvoidonMessage(WebSocket conn, ByteBuffer message)Callback for binary messages received from the remote hostvoidonOpen(WebSocket conn, ClientHandshake handshake)Called after an opening handshake has been performed and the given websocket is ready to be written on.voidonStart()Called when the server started up successfully.voidsend(String tag, String message)voidsetEventDispatcher(CrossEventDispatcher ed)-
Methods inherited from class org.java_websocket.server.WebSocketServer
addConnection, allocateBuffers, broadcast, broadcast, broadcast, broadcast, broadcast, broadcast, connections, createBuffer, getAddress, getConnections, getDraft, getLocalSocketAddress, getPort, getRemoteSocketAddress, getWebSocketFactory, onCloseInitiated, onClosing, onConnect, onFragment, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketHandshakeReceivedAsServer, onWebsocketMessage, onWebsocketMessage, onWebsocketMessageFragment, onWebsocketOpen, onWriteDemand, queue, releaseBuffers, removeConnection, run, setWebSocketFactory, start, stop, stop
-
Methods inherited from class org.java_websocket.AbstractWebSocket
getConnectionLostTimeout, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setReuseAddr, setTcpNoDelay, startConnectionLostTimer, stopConnectionLostTimer
-
Methods inherited from class org.java_websocket.WebSocketAdapter
onWebsocketHandshakeReceivedAsClient, onWebsocketHandshakeSentAsClient, onWebsocketPing, onWebsocketPong
-
-
-
-
Field Detail
-
DEBUG
public static Boolean DEBUG
-
-
Constructor Detail
-
WsServer
public WsServer(int port) throws UnknownHostException- Throws:
UnknownHostException
-
WsServer
public WsServer(InetSocketAddress address)
-
-
Method Detail
-
onOpen
public void onOpen(WebSocket conn, ClientHandshake handshake)
Description copied from class:WebSocketServerCalled after an opening handshake has been performed and the given websocket is ready to be written on.- Specified by:
onOpenin classWebSocketServer- Parameters:
conn- The WebSocket instance this event is occuring on.handshake- The handshake of the websocket instance
-
setEventDispatcher
public void setEventDispatcher(CrossEventDispatcher ed)
-
onClose
public void onClose(WebSocket conn, int code, String reason, boolean remote)
Description copied from class:WebSocketServerCalled after the websocket connection has been closed.- Specified by:
onClosein classWebSocketServer- Parameters:
conn- The WebSocket instance this event is occuring on.code- The codes can be looked up here:CloseFramereason- Additional information stringremote- Returns whether or not the closing of the connection was initiated by the remote host.
-
onMessage
public void onMessage(WebSocket conn, String message)
Description copied from class:WebSocketServerCallback for string messages received from the remote host- Specified by:
onMessagein classWebSocketServer- Parameters:
conn- The WebSocket instance this event is occuring on.message- The UTF-8 decoded message that was received.- See Also:
WebSocketServer.onMessage(WebSocket, ByteBuffer)
-
onMessage
public void onMessage(WebSocket conn, ByteBuffer message)
Description copied from class:WebSocketServerCallback for binary messages received from the remote host- Overrides:
onMessagein classWebSocketServer- Parameters:
conn- The WebSocket instance this event is occurring on.message- The binary message that was received.- See Also:
WebSocketServer.onMessage(WebSocket, ByteBuffer)
-
onError
public void onError(WebSocket conn, Exception ex)
Description copied from class:WebSocketServerCalled when errors occurs. If an error causes the websocket connection to failWebSocketServer.onClose(WebSocket, int, String, boolean)will be called additionally.
This method will be called primarily because of IO or protocol errors.
If the given exception is an RuntimeException that probably means that you encountered a bug.- Specified by:
onErrorin classWebSocketServer- Parameters:
conn- Can be null if there error does not belong to one specific websocket. For example if the servers port could not be bound.ex- The exception causing this error
-
onStart
public void onStart()
Description copied from class:WebSocketServerCalled when the server started up successfully. If any error occured, onError is called instead.- Specified by:
onStartin classWebSocketServer
-
getInstance
public static Object getInstance(com.basis.bbj.proxies.BBjAPI api, int port) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableKeyException, KeyManagementException
-
-