com.ning.http.client.providers.netty
Class NettyWebSocket

java.lang.Object
  extended by com.ning.http.client.providers.netty.NettyWebSocket
All Implemented Interfaces:
WebSocket

public class NettyWebSocket
extends Object
implements WebSocket


Constructor Summary
NettyWebSocket(org.jboss.netty.channel.Channel channel)
           
 
Method Summary
 WebSocket addWebSocketListener(WebSocketListener l)
          Add a WebSocketListener
 void close()
          Close the WebSocket.
 boolean isOpen()
          Returns true if the WebSocket is open/connected.
protected  void onClose()
           
protected  void onClose(int code, String reason)
           
protected  void onError(Throwable t)
           
protected  void onMessage(byte[] message)
           
protected  void onTextMessage(String message)
           
 WebSocket removeWebSocketListener(WebSocketListener l)
          Add a WebSocketListener
 WebSocket sendMessage(byte[] message)
          Send a byte message.
 WebSocket sendPing(byte[] payload)
          Send a ping with an optional payload (limited to 125 bytes or less).
 WebSocket sendPong(byte[] payload)
          Send a ping with an optional payload (limited to 125 bytes or less).
 WebSocket sendTextMessage(String message)
          Send a text message
 WebSocket stream(byte[] fragment, boolean last)
          Allows streaming of multiple binary fragments.
 WebSocket stream(byte[] fragment, int offset, int len, boolean last)
          Allows streaming of multiple binary fragments.
 WebSocket streamText(String fragment, boolean last)
          Allows streaming of multiple text fragments.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NettyWebSocket

public NettyWebSocket(org.jboss.netty.channel.Channel channel)
Method Detail

sendMessage

public WebSocket sendMessage(byte[] message)
Description copied from interface: WebSocket
Send a byte message.

Specified by:
sendMessage in interface WebSocket
Parameters:
message - a byte message
Returns:
this

stream

public WebSocket stream(byte[] fragment,
                        boolean last)
Description copied from interface: WebSocket
Allows streaming of multiple binary fragments.

Specified by:
stream in interface WebSocket
Parameters:
fragment - binary fragment.
last - flag indicating whether or not this is the last fragment.
Returns:
this.

stream

public WebSocket stream(byte[] fragment,
                        int offset,
                        int len,
                        boolean last)
Description copied from interface: WebSocket
Allows streaming of multiple binary fragments.

Specified by:
stream in interface WebSocket
Parameters:
fragment - binary fragment.
offset - starting offset.
len - length.
last - flag indicating whether or not this is the last fragment.
Returns:
this.

sendTextMessage

public WebSocket sendTextMessage(String message)
Description copied from interface: WebSocket
Send a text message

Specified by:
sendTextMessage in interface WebSocket
Parameters:
message - a text message
Returns:
this.

streamText

public WebSocket streamText(String fragment,
                            boolean last)
Description copied from interface: WebSocket
Allows streaming of multiple text fragments.

Specified by:
streamText in interface WebSocket
Parameters:
fragment - text fragment.
last - flag indicating whether or not this is the last fragment.
Returns:
this.

sendPing

public WebSocket sendPing(byte[] payload)
Description copied from interface: WebSocket
Send a ping with an optional payload (limited to 125 bytes or less).

Specified by:
sendPing in interface WebSocket
Parameters:
payload - the ping payload.
Returns:
this.

sendPong

public WebSocket sendPong(byte[] payload)
Description copied from interface: WebSocket
Send a ping with an optional payload (limited to 125 bytes or less).

Specified by:
sendPong in interface WebSocket
Parameters:
payload - the pong payload.
Returns:
this.

addWebSocketListener

public WebSocket addWebSocketListener(WebSocketListener l)
Description copied from interface: WebSocket
Add a WebSocketListener

Specified by:
addWebSocketListener in interface WebSocket
Parameters:
l - a WebSocketListener
Returns:
this

removeWebSocketListener

public WebSocket removeWebSocketListener(WebSocketListener l)
Description copied from interface: WebSocket
Add a WebSocketListener

Specified by:
removeWebSocketListener in interface WebSocket
Parameters:
l - a WebSocketListener
Returns:
this

isOpen

public boolean isOpen()
Description copied from interface: WebSocket
Returns true if the WebSocket is open/connected.

Specified by:
isOpen in interface WebSocket
Returns:
true if the WebSocket is open/connected.

close

public void close()
Description copied from interface: WebSocket
Close the WebSocket.

Specified by:
close in interface WebSocket

onMessage

protected void onMessage(byte[] message)

onTextMessage

protected void onTextMessage(String message)

onError

protected void onError(Throwable t)

onClose

protected void onClose()

onClose

protected void onClose(int code,
                       String reason)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.