org.glassfish.grizzly.websockets
Class WebSocketApplication

java.lang.Object
  extended by org.glassfish.grizzly.websockets.WebSocketAdapter
      extended by org.glassfish.grizzly.websockets.WebSocketApplication
All Implemented Interfaces:
WebSocketListener

public abstract class WebSocketApplication
extends WebSocketAdapter

Abstract server-side WebSocket application, which will handle application WebSockets events.

Author:
Alexey Stashok

Constructor Summary
WebSocketApplication()
           
 
Method Summary
protected  boolean add(WebSocket socket)
           
 WebSocket createSocket(ProtocolHandler handler, WebSocketListener... listeners)
           
 java.util.List<java.lang.String> getSupportedExtensions()
           
 java.util.List<java.lang.String> getSupportedProtocols(java.util.List<java.lang.String> subProtocol)
           
protected  java.util.Set<WebSocket> getWebSockets()
          Returns a set of WebSockets, registered with the application.
protected  void handshake(HandShake handshake)
          Method is called, when initial WebSocket handshake process was completed, but WebSocketApplication may perform additional validation such as subprotocol or extension negotiation.
abstract  boolean isApplicationRequest(HttpRequestPacket request)
          Checks application specific criteria to determine if this application can process the Request as a WebSocket connection.
 void onClose(WebSocket socket, DataFrame frame)
           
 void onConnect(WebSocket socket)
           
 boolean remove(WebSocket socket)
           
 boolean upgrade(HttpRequestPacket request)
          Checks protocol specific information and queries #isApplicationRequest(Request) to see if the Request should be upgraded.
 
Methods inherited from class org.glassfish.grizzly.websockets.WebSocketAdapter
onFragment, onFragment, onMessage, onMessage, onPing, onPong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebSocketApplication

public WebSocketApplication()
Method Detail

getWebSockets

protected java.util.Set<WebSocket> getWebSockets()
Returns a set of WebSockets, registered with the application. The returned set is unmodifiable, the possible modifications may cause exceptions.

Returns:
a set of WebSockets, registered with the application.

add

protected boolean add(WebSocket socket)

remove

public boolean remove(WebSocket socket)

createSocket

public WebSocket createSocket(ProtocolHandler handler,
                              WebSocketListener... listeners)

handshake

protected void handshake(HandShake handshake)
                  throws HandshakeException
Method is called, when initial WebSocket handshake process was completed, but WebSocketApplication may perform additional validation such as subprotocol or extension negotiation.

Throws:
HandshakeException - error occurred during the handshake.

onClose

public void onClose(WebSocket socket,
                    DataFrame frame)
Specified by:
onClose in interface WebSocketListener
Overrides:
onClose in class WebSocketAdapter

onConnect

public void onConnect(WebSocket socket)
Specified by:
onConnect in interface WebSocketListener
Overrides:
onConnect in class WebSocketAdapter

upgrade

public final boolean upgrade(HttpRequestPacket request)
Checks protocol specific information and queries #isApplicationRequest(Request) to see if the Request should be upgraded.

Returns:
true if the request should be upgraded to a WebSocket connection

isApplicationRequest

public abstract boolean isApplicationRequest(HttpRequestPacket request)
Checks application specific criteria to determine if this application can process the Request as a WebSocket connection.

Parameters:
request -
Returns:
true if this application can service this Request

getSupportedExtensions

public java.util.List<java.lang.String> getSupportedExtensions()

getSupportedProtocols

public java.util.List<java.lang.String> getSupportedProtocols(java.util.List<java.lang.String> subProtocol)


Copyright © 2011 Oracle Corpration. All Rights Reserved.