Apache Tomcat 7.0.28

org.apache.catalina.websocket
Class StreamInbound

java.lang.Object
  extended by org.apache.catalina.websocket.StreamInbound
All Implemented Interfaces:
UpgradeInbound
Direct Known Subclasses:
MessageInbound

public abstract class StreamInbound
extends Object
implements UpgradeInbound

Base implementation of the class used to process WebSocket connections based on streams. Applications should extend this class to provide application specific functionality. Applications that wish to operate on a message basis rather than a stream basis should use MessageInbound.


Constructor Summary
StreamInbound()
           
 
Method Summary
 int getOutboundByteBufferSize()
           
 int getOutboundCharBufferSize()
           
 int getReadTimeout()
          This default implementation sets the read timeout to infinite and expects the WebSocket application to close the connection when it is no longer required.
 WsOutbound getWsOutbound()
          Obtain the outbound side of this WebSocket connection used for writing data to the client.
protected abstract  void onBinaryData(InputStream is)
          This method is called when there is a binary WebSocket message available to process.
protected  void onClose(int status)
          Intended to be overridden by sub-classes that wish to be notified when the outbound connection is closed.
 AbstractEndpoint.Handler.SocketState onData()
           
protected  void onOpen(WsOutbound outbound)
          Intended to be overridden by sub-classes that wish to be notified when the outbound connection is established.
protected abstract  void onTextData(Reader r)
          This method is called when there is a textual WebSocket message available to process.
 void onUpgradeComplete()
           
 void setOutboundByteBufferSize(int outboundByteBufferSize)
          This only applies to the WsOutbound instance returned from getWsOutbound() created by a subsequent call to setUpgradeOutbound(UpgradeOutbound).
 void setOutboundCharBufferSize(int outboundCharBufferSize)
          This only applies to the WsOutbound instance returned from getWsOutbound() created by a subsequent call to setUpgradeOutbound(UpgradeOutbound).
 void setUpgradeOutbound(UpgradeOutbound upgradeOutbound)
           
 void setUpgradeProcessor(UpgradeProcessor<?> processor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamInbound

public StreamInbound()
Method Detail

getOutboundByteBufferSize

public int getOutboundByteBufferSize()

setOutboundByteBufferSize

public void setOutboundByteBufferSize(int outboundByteBufferSize)
This only applies to the WsOutbound instance returned from getWsOutbound() created by a subsequent call to setUpgradeOutbound(UpgradeOutbound). The current WsOutbound instance, if any, is not affected.

Parameters:
outboundByteBufferSize -

getOutboundCharBufferSize

public int getOutboundCharBufferSize()

setOutboundCharBufferSize

public void setOutboundCharBufferSize(int outboundCharBufferSize)
This only applies to the WsOutbound instance returned from getWsOutbound() created by a subsequent call to setUpgradeOutbound(UpgradeOutbound). The current WsOutbound instance, if any, is not affected.

Parameters:
outboundCharBufferSize -

setUpgradeOutbound

public final void setUpgradeOutbound(UpgradeOutbound upgradeOutbound)
Specified by:
setUpgradeOutbound in interface UpgradeInbound

setUpgradeProcessor

public final void setUpgradeProcessor(UpgradeProcessor<?> processor)
Specified by:
setUpgradeProcessor in interface UpgradeInbound

getWsOutbound

public final WsOutbound getWsOutbound()
Obtain the outbound side of this WebSocket connection used for writing data to the client.


onData

public final AbstractEndpoint.Handler.SocketState onData()
                                                  throws IOException
Specified by:
onData in interface UpgradeInbound
Throws:
IOException

onUpgradeComplete

public final void onUpgradeComplete()
Specified by:
onUpgradeComplete in interface UpgradeInbound

onOpen

protected void onOpen(WsOutbound outbound)
Intended to be overridden by sub-classes that wish to be notified when the outbound connection is established. The default implementation is a NO-OP.

Parameters:
outbound - The outbound WebSocket connection.

onClose

protected void onClose(int status)
Intended to be overridden by sub-classes that wish to be notified when the outbound connection is closed. The default implementation is a NO-OP.

Parameters:
status - The status code of the close reason.

onBinaryData

protected abstract void onBinaryData(InputStream is)
                              throws IOException
This method is called when there is a binary WebSocket message available to process. The message is presented via a stream and may be formed from one or more frames. The number of frames used to transmit the message is not made visible to the application.

Parameters:
is - The WebSocket message
Throws:
IOException - If a problem occurs processing the message. Any exception will trigger the closing of the WebSocket connection.

onTextData

protected abstract void onTextData(Reader r)
                            throws IOException
This method is called when there is a textual WebSocket message available to process. The message is presented via a reader and may be formed from one or more frames. The number of frames used to transmit the message is not made visible to the application.

Parameters:
r - The WebSocket message
Throws:
IOException - If a problem occurs processing the message. Any exception will trigger the closing of the WebSocket connection.

getReadTimeout

public int getReadTimeout()
This default implementation sets the read timeout to infinite and expects the WebSocket application to close the connection when it is no longer required. Applications wishing to set an explicit timeout may override this method and return a value of their choice.

Specified by:
getReadTimeout in interface UpgradeInbound
Returns:
The read timeout in milliseconds or -1 for infinite

Apache Tomcat 7.0.28

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