@WebSocket
public class PeerWebSocket
extends java.lang.Object
| Constructor and Description | 
|---|
| PeerWebSocket()Create a client socket | 
| PeerWebSocket(PeerServlet peerServlet)Create a server socket | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Close the WebSocket | 
| java.lang.String | doPost(java.lang.String request)Process a POST request by sending the request message and then
 waiting for a response. | 
| java.net.InetSocketAddress | getRemoteAddress()Return the remote address for this connection | 
| boolean | isOpen()Check if we have a WebSocket connection | 
| void | onClose(int statusCode,
       java.lang.String reason)WebSocket session has been closed | 
| void | onConnect(org.eclipse.jetty.websocket.api.Session session)WebSocket connection complete | 
| void | onMessage(byte[] inbuf,
         int off,
         int len)Process a socket message | 
| void | sendResponse(long requestId,
            java.lang.String response)Send POST response
 This method is used by the connection acceptor to return the POST response | 
| boolean | startClient(java.net.URI uri)Start a client session | 
public PeerWebSocket()
public PeerWebSocket(PeerServlet peerServlet)
peerServlet - Servlet for request processingpublic boolean startClient(java.net.URI uri)
                    throws java.io.IOException
uri - Server URIjava.io.IOException - I/O error occurred@OnWebSocketConnect public void onConnect(org.eclipse.jetty.websocket.api.Session session)
session - WebSocket sessionpublic boolean isOpen()
public java.net.InetSocketAddress getRemoteAddress()
public java.lang.String doPost(java.lang.String request)
                        throws java.io.IOException
request - Request messagejava.io.IOException - I/O error occurredpublic void sendResponse(long requestId,
                         java.lang.String response)
                  throws java.io.IOException
requestId - Request identifierresponse - Response messagejava.io.IOException - I/O error occurred@OnWebSocketMessage
public void onMessage(byte[] inbuf,
                                          int off,
                                          int len)
inbuf - Message bufferoff - Starting offsetlen - Message length@OnWebSocketClose
public void onClose(int statusCode,
                                      java.lang.String reason)
statusCode - Status codereason - Reason messagepublic void close()