websocket4j.server
Class WebSocket
java.lang.Object
websocket4j.AbstractWebSocket
websocket4j.server.WebSocket
public class WebSocket
- extends AbstractWebSocket
Socket wrapper that implements server side of the WebSocket protocol.
http://www.whatwg.org/specs/web-socket-protocol/
Constructor Summary |
WebSocket(java.net.Socket socket)
Creates new web socket ready for use. |
WebSocket(java.net.Socket socket,
java.lang.Integer timeout)
Creates new web socket ready for use, if opening handshake doesn't finish
in given time, socket creation will be aborted (if given time is 0, it
will wait as long as needed). |
Method Summary |
java.lang.String |
getRequestUri()
Returns Request-URI part of the handshake header as specified in HTTP
protocol. |
protected void |
handshake(java.lang.Object... args)
Performs an opening handshake with the client. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WebSocket
public WebSocket(java.net.Socket socket)
throws java.io.IOException
- Creates new web socket ready for use.
- Parameters:
socket
- socket to use for communication
- Throws:
java.io.IOException
- thrown when there is a problem with connection or protocol
error
WebSocket
public WebSocket(java.net.Socket socket,
java.lang.Integer timeout)
throws java.io.IOException
- Creates new web socket ready for use, if opening handshake doesn't finish
in given time, socket creation will be aborted (if given time is 0, it
will wait as long as needed).
- Parameters:
socket
- socket to use for communicationtimeout
- maximum time for handshake in milliseconds
- Throws:
java.io.IOException
- thrown when there is a problem with connection or protocol
error
getRequestUri
public java.lang.String getRequestUri()
- Returns Request-URI part of the handshake header as specified in HTTP
protocol. This will be null if the handshake failed before Request-URI
was sent.
- Returns:
- Request-URI part of the handshake header.
handshake
protected void handshake(java.lang.Object... args)
throws java.io.IOException,
java.security.NoSuchAlgorithmException
- Performs an opening handshake with the client. If this method completes
successfully, a connection with the client is established.
- Specified by:
handshake
in class AbstractWebSocket
- Parameters:
args
- should be empty
- Throws:
java.io.IOException
- thrown when there is a problem in socket communication or
client does not follow the handshake protocol
java.security.NoSuchAlgorithmException
- thrown when JVM doesn't support MD5 algorithm