org.java_websocket
Interface WebSocket

All Known Implementing Classes:
WebSocketImpl

public interface WebSocket


Nested Class Summary
static class WebSocket.READYSTATE
           
static class WebSocket.Role
           
 
Field Summary
static int DEFAULT_PORT
          The default port of WebSockets, as defined in the spec.
static int DEFAULT_WSS_PORT
           
 
Method Summary
 void close()
          Convenience function which behaves like close(CloseFrame.NORMAL)
 void close(int code)
           
 void close(int code, String message)
          sends the closing handshake.
 void closeConnection(int code, String message)
          This will close the connection immediately without a proper close handshake.
 Draft getDraft()
           
 InetSocketAddress getLocalSocketAddress()
           
 WebSocket.READYSTATE getReadyState()
          Retrieve the WebSocket 'readyState'.
 InetSocketAddress getRemoteSocketAddress()
           
 boolean hasBufferedData()
           
 boolean isClosed()
          Returns whether the close handshake has been completed and the socket is closed.
 boolean isClosing()
           
 boolean isConnecting()
           
 boolean isFlushAndClose()
          Returns true when no further frames may be submitted
This happens before the socket connection is closed.
 boolean isOpen()
           
 void send(byte[] bytes)
           
 void send(ByteBuffer bytes)
          Send Binary data (plain bytes) to the other end.
 void send(String text)
          Send Text data to the other end.
 void sendFrame(Framedata framedata)
           
 

Field Detail

DEFAULT_PORT

static final int DEFAULT_PORT
The default port of WebSockets, as defined in the spec. If the nullary constructor is used, DEFAULT_PORT will be the port the WebSocketServer is binded to. Note that ports under 1024 usually require root permissions.

See Also:
Constant Field Values

DEFAULT_WSS_PORT

static final int DEFAULT_WSS_PORT
See Also:
Constant Field Values
Method Detail

close

void close(int code,
           String message)
sends the closing handshake. may be send in response to an other handshake.


close

void close(int code)

close

void close()
Convenience function which behaves like close(CloseFrame.NORMAL)


closeConnection

void closeConnection(int code,
                     String message)
This will close the connection immediately without a proper close handshake. The code and the message therefore won't be transfered over the wire also they will be forwarded to onClose/onWebsocketClose.


send

void send(String text)
          throws NotYetConnectedException
Send Text data to the other end.

Throws:
IllegalArgumentException
NotYetConnectedException

send

void send(ByteBuffer bytes)
          throws IllegalArgumentException,
                 NotYetConnectedException
Send Binary data (plain bytes) to the other end.

Throws:
IllegalArgumentException
NotYetConnectedException

send

void send(byte[] bytes)
          throws IllegalArgumentException,
                 NotYetConnectedException
Throws:
IllegalArgumentException
NotYetConnectedException

sendFrame

void sendFrame(Framedata framedata)

hasBufferedData

boolean hasBufferedData()

getRemoteSocketAddress

InetSocketAddress getRemoteSocketAddress()

getLocalSocketAddress

InetSocketAddress getLocalSocketAddress()

isConnecting

boolean isConnecting()

isOpen

boolean isOpen()

isClosing

boolean isClosing()

isFlushAndClose

boolean isFlushAndClose()
Returns true when no further frames may be submitted
This happens before the socket connection is closed.


isClosed

boolean isClosed()
Returns whether the close handshake has been completed and the socket is closed.


getDraft

Draft getDraft()

getReadyState

WebSocket.READYSTATE getReadyState()
Retrieve the WebSocket 'readyState'. This represents the state of the connection. It returns a numerical value, as per W3C WebSockets specs.

Returns:
Returns '0 = CONNECTING', '1 = OPEN', '2 = CLOSING' or '3 = CLOSED'


Copyright © 2013 Pusher. All Rights Reserved.