org.glassfish.grizzly.websockets
Class DefaultWebSocket

java.lang.Object
  extended by org.glassfish.grizzly.websockets.DefaultWebSocket
All Implemented Interfaces:
WebSocket
Direct Known Subclasses:
WebSocketClient

public class DefaultWebSocket
extends java.lang.Object
implements WebSocket


Field Summary
protected  ProtocolHandler protocolHandler
           
 
Fields inherited from interface org.glassfish.grizzly.websockets.WebSocket
ABNORMAL_CLOSE, END_POINT_GOING_DOWN, INVALID_DATA, MESSAGE_TOO_LARGE, NO_STATUS_CODE, NORMAL_CLOSURE, PROTOCOL_ERROR
 
Constructor Summary
DefaultWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners)
           
 
Method Summary
 boolean add(WebSocketListener listener)
           
 void close()
           
 void close(int code)
           
 void close(int code, java.lang.String reason)
           
 java.util.Collection<WebSocketListener> getListeners()
           
 boolean isConnected()
           
 void onClose(DataFrame frame)
           
 void onConnect()
           
 void onFragment(boolean last, byte[] fragment)
           
 void onFragment(boolean last, java.lang.String fragment)
           
 void onMessage(byte[] data)
           
 void onMessage(java.lang.String text)
           
 void onPing(DataFrame frame)
           
 void onPong(DataFrame frame)
           
 boolean remove(WebSocketListener listener)
           
 GrizzlyFuture<DataFrame> send(byte[] data)
          Send a text frame
 GrizzlyFuture<DataFrame> send(java.lang.String data)
          Send a text frame
 void setClosed()
           
 GrizzlyFuture<DataFrame> stream(boolean last, byte[] bytes, int off, int len)
           
 GrizzlyFuture<DataFrame> stream(boolean last, java.lang.String fragment)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

protocolHandler

protected final ProtocolHandler protocolHandler
Constructor Detail

DefaultWebSocket

public DefaultWebSocket(ProtocolHandler protocolHandler,
                        WebSocketListener... listeners)
Method Detail

getListeners

public java.util.Collection<WebSocketListener> getListeners()

add

public final boolean add(WebSocketListener listener)
Specified by:
add in interface WebSocket

remove

public final boolean remove(WebSocketListener listener)
Specified by:
remove in interface WebSocket

isConnected

public boolean isConnected()
Specified by:
isConnected in interface WebSocket

setClosed

public void setClosed()

onClose

public void onClose(DataFrame frame)
Specified by:
onClose in interface WebSocket

onConnect

public void onConnect()
Specified by:
onConnect in interface WebSocket

onFragment

public void onFragment(boolean last,
                       byte[] fragment)
Specified by:
onFragment in interface WebSocket

onFragment

public void onFragment(boolean last,
                       java.lang.String fragment)
Specified by:
onFragment in interface WebSocket

onMessage

public void onMessage(byte[] data)
Specified by:
onMessage in interface WebSocket

onMessage

public void onMessage(java.lang.String text)
Specified by:
onMessage in interface WebSocket

onPing

public void onPing(DataFrame frame)
Specified by:
onPing in interface WebSocket

onPong

public void onPong(DataFrame frame)
Specified by:
onPong in interface WebSocket

close

public void close()
Specified by:
close in interface WebSocket

close

public void close(int code)
Specified by:
close in interface WebSocket

close

public void close(int code,
                  java.lang.String reason)
Specified by:
close in interface WebSocket

send

public GrizzlyFuture<DataFrame> send(byte[] data)
Description copied from interface: WebSocket
Send a text frame

Specified by:
send in interface WebSocket
Returns:
GrizzlyFuture, which could be used to control the sending completion state.

send

public GrizzlyFuture<DataFrame> send(java.lang.String data)
Description copied from interface: WebSocket
Send a text frame

Specified by:
send in interface WebSocket
Returns:
GrizzlyFuture, which could be used to control the sending completion state.

stream

public GrizzlyFuture<DataFrame> stream(boolean last,
                                       java.lang.String fragment)
Specified by:
stream in interface WebSocket

stream

public GrizzlyFuture<DataFrame> stream(boolean last,
                                       byte[] bytes,
                                       int off,
                                       int len)
Specified by:
stream in interface WebSocket


Copyright © 2011 Oracle Corpration. All Rights Reserved.