Class WebSocketComm
- java.lang.Object
- com.iizix.nio.WebSocketCommNIO
- com.iizix.comm.WebSocketComm
- All Implemented Interfaces:
IWebSocketComm
public class WebSocketComm extends WebSocketCommNIO
Class to handle the WebSocket protocol.The WebSocket Client pure socket implementation. This implementation is based on RFC 6455 "The WebSocket Protocol", also supporting the older "draft-ietf-hybi-thewebsocketprotocol-00" also called "Hixie 75/76" versions.
The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host that has opted-in to communications from that code. The security model used for this is the origin-based security model commonly used by web browsers. The protocol consists of an opening handshake followed by basic message framing, layered over TCP. The goal of this technology is to provide a mechanism for browser-based applications that need two-way communication with servers that does not rely on opening multiple HTTP connections (e.g., using XMLHttpRequest or <iframe>s and long polling).
To be implemented (fragmentation compliance with RFC 6455).
- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description WebSocketCommProps
properties
The WebSocket (and Socket) properties.Fields inherited from class com.iizix.nio.WebSocketCommNIO
requestURI
Constructor Summary
Constructors Constructor Description WebSocketComm(WebSocketCommProps properties, Worker worker, WebSocketCommListener listener, javax.net.ssl.SSLEngine engine)
Creates a new WebSocket Client Communication channel as UNINITIALIZED.WebSocketComm(WebSocketCommProps properties, Worker worker, java.nio.channels.SocketChannel channel, WebSocketCommListener listener, WebSocketAcceptor acceptor)
Creates a new WebSocket Client Communication channel from an accepted socket connection and sets it to as CHECKING_CONNECT_REQUEST, before the negotiation is completed and then becomes CONNECTED.
Method Summary
Methods inherited from class com.iizix.nio.WebSocketCommNIO
areBinaryDataFramesSupported, close, close, close, getAttachment, getDomain, getPort, getRemoteAddr, getRemoteHost, getSocketAddress, getState, getSubProtocol, isClosed, isClosing, isConnected, isConnecting, isSecure, open, open, send, send, sendHeartBeat, serverInitializeComm, setAttachment, setSubProtocol
Field Detail
properties
public final WebSocketCommProps properties
The WebSocket (and Socket) properties.
Constructor Detail
WebSocketComm
public WebSocketComm(WebSocketCommProps properties, Worker worker, WebSocketCommListener listener, javax.net.ssl.SSLEngine engine) throws java.io.IOException
Creates a new WebSocket Client Communication channel as UNINITIALIZED.- Parameters:
properties
- The WebSocket properties.worker
- The worker thread for socket processing.listener
- The listener for WebSocket events.engine
- The SSL engine or null for plain connection.- Throws:
java.io.IOException
- For SSL errors.
WebSocketComm
public WebSocketComm(WebSocketCommProps properties, Worker worker, java.nio.channels.SocketChannel channel, WebSocketCommListener listener, WebSocketAcceptor acceptor) throws java.io.IOException
Creates a new WebSocket Client Communication channel from an accepted socket connection and sets it to as CHECKING_CONNECT_REQUEST, before the negotiation is completed and then becomes CONNECTED.- Parameters:
properties
- The WebSocket properties.worker
- The worker thread for socket processing.channel
- The SocketChannel instance that has been accepted.listener
- The listener for WebSocket (server) events.acceptor
- The URI acceptor for WebSocket requests.- Throws:
java.io.IOException
- For I/O exceptions.