Apache Tomcat 7.0.37

org.apache.catalina.websocket
Class WsOutbound

java.lang.Object
  extended by org.apache.catalina.websocket.WsOutbound

public class WsOutbound
extends Object

Provides the means to write WebSocket messages to the client. All methods that write to the client (or update a buffer that is later written to the client) are synchronized to prevent multiple threads trying to write to the client at the same time.


Field Summary
static int DEFAULT_BUFFER_SIZE
           
 
Constructor Summary
WsOutbound(UpgradeOutbound upgradeOutbound)
           
WsOutbound(UpgradeOutbound upgradeOutbound, int byteBufferSize, int charBufferSize)
           
 
Method Summary
 void close(int status, ByteBuffer data)
          Send a close message to the client
protected  void close(WsFrame frame)
          Respond to a client close by sending a close that echoes the status code and message.
 void flush()
          Flush any message (binary or textual) that may be buffered.
 void ping(ByteBuffer data)
          Send a ping message to the client
 void pong(ByteBuffer data)
          Send a pong message to the client
 void writeBinaryData(int b)
          Adds the data to the buffer for binary data.
 void writeBinaryMessage(ByteBuffer msgBb)
          Flush any message (binary or textual) that may be buffered and then send a WebSocket binary message as a single frame with the provided buffer as the payload of the message.
 void writeTextData(char c)
          Adds the data to the buffer for textual data.
 void writeTextMessage(CharBuffer msgCb)
          Flush any message (binary or textual) that may be buffered and then send a WebSocket text message as a single frame with the provided buffer as the payload of the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

WsOutbound

public WsOutbound(UpgradeOutbound upgradeOutbound)

WsOutbound

public WsOutbound(UpgradeOutbound upgradeOutbound,
                  int byteBufferSize,
                  int charBufferSize)
Method Detail

writeBinaryData

public void writeBinaryData(int b)
                     throws IOException
Adds the data to the buffer for binary data. If a textual message is currently in progress that message will be completed and a new binary message started. If the buffer for binary data is full, the buffer will be flushed and a new binary continuation fragment started.

Parameters:
b - The byte (only the least significant byte is used) of data to send to the client.
Throws:
IOException - If a flush is required and an error occurs writing the WebSocket frame to the client

writeTextData

public void writeTextData(char c)
                   throws IOException
Adds the data to the buffer for textual data. If a binary message is currently in progress that message will be completed and a new textual message started. If the buffer for textual data is full, the buffer will be flushed and a new textual continuation fragment started.

Parameters:
c - The character to send to the client.
Throws:
IOException - If a flush is required and an error occurs writing the WebSocket frame to the client

writeBinaryMessage

public void writeBinaryMessage(ByteBuffer msgBb)
                        throws IOException
Flush any message (binary or textual) that may be buffered and then send a WebSocket binary message as a single frame with the provided buffer as the payload of the message.

Parameters:
msgBb - The buffer containing the payload
Throws:
IOException - If an error occurs writing to the client

writeTextMessage

public void writeTextMessage(CharBuffer msgCb)
                      throws IOException
Flush any message (binary or textual) that may be buffered and then send a WebSocket text message as a single frame with the provided buffer as the payload of the message.

Parameters:
msgCb - The buffer containing the payload
Throws:
IOException - If an error occurs writing to the client

flush

public void flush()
           throws IOException
Flush any message (binary or textual) that may be buffered.

Throws:
IOException - If an error occurs writing to the client

close

protected void close(WsFrame frame)
              throws IOException
Respond to a client close by sending a close that echoes the status code and message.

Parameters:
frame - The close frame received from a client
Throws:
IOException - If an error occurs writing to the client

close

public void close(int status,
                  ByteBuffer data)
           throws IOException
Send a close message to the client

Parameters:
status - Must be a valid status code or zero to send no code
data - Optional message. If message is defined, a valid status code must be provided.
Throws:
IOException - If an error occurs writing to the client

pong

public void pong(ByteBuffer data)
          throws IOException
Send a pong message to the client

Parameters:
data - Optional message.
Throws:
IOException - If an error occurs writing to the client

ping

public void ping(ByteBuffer data)
          throws IOException
Send a ping message to the client

Parameters:
data - Optional message.
Throws:
IOException - If an error occurs writing to the client

Apache Tomcat 7.0.37

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.