Class FrameCollector
- java.lang.Object
-
- org.simpleframework.http.socket.service.FrameCollector
-
- All Implemented Interfaces:
java.lang.Runnable
,Operation
class FrameCollector extends java.lang.Object implements Operation
TheFrameCollector
operation is used to collect frames from a channel and dispatch them to aFrameListener
. To ensure that stale connections do not linger any connection that does not send a control ping or pong frame within two minutes will be terminated and the close control frame will be sent.
-
-
Field Summary
Fields Modifier and Type Field Description private Channel
channel
This is the underlying channel for this frame collector.private ByteCursor
cursor
This is the cursor used to maintain a stream seek position.private FrameProcessor
processor
This decodes the frame bytes from the channel and processes it.private Reactor
reactor
This is the reactor used to schedule this operation for reads.private Trace
trace
This is the tracer that is used to trace the frame collection.
-
Constructor Summary
Constructors Constructor Description FrameCollector(FrameEncoder encoder, Session session, Request request, Reactor reactor)
Constructor for theFrameCollector
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
This is called when a read operation has timed out.java.nio.channels.SelectableChannel
getChannel()
This is the channel associated with this collector.Trace
getTrace()
This is used to acquire the trace object that is associated with the operation.void
register(FrameListener listener)
This is used to register aFrameListener
to this instance.void
remove(FrameListener listener)
This is used to remove aFrameListener
from this instance.void
run()
This is used to execute the collection operation.
-
-
-
Field Detail
-
processor
private final FrameProcessor processor
This decodes the frame bytes from the channel and processes it.
-
cursor
private final ByteCursor cursor
This is the cursor used to maintain a stream seek position.
-
channel
private final Channel channel
This is the underlying channel for this frame collector.
-
reactor
private final Reactor reactor
This is the reactor used to schedule this operation for reads.
-
trace
private final Trace trace
This is the tracer that is used to trace the frame collection.
-
-
Constructor Detail
-
FrameCollector
public FrameCollector(FrameEncoder encoder, Session session, Request request, Reactor reactor)
Constructor for theFrameCollector
object. This is used to create a collector that will process and dispatch web socket frames as defined by RFC 6455.- Parameters:
encoder
- this is the encoder used to send messagessession
- this is the web socket sessionchannel
- this is the underlying TCP communication channelreactor
- this is the reactor used for read notifications
-
-
Method Detail
-
getTrace
public Trace getTrace()
This is used to acquire the trace object that is associated with the operation. A trace object is used to collection details on what operations are being performed. For instance it may contain information relating to I/O events or errors.
-
getChannel
public java.nio.channels.SelectableChannel getChannel()
This is the channel associated with this collector. This is used to register for notification of read events. If at any time the remote endpoint is closed then this will cause the collector to perform a final execution before closing.- Specified by:
getChannel
in interfaceOperation
- Returns:
- this returns the selectable TCP channel
-
register
public void register(FrameListener listener)
This is used to register aFrameListener
to this instance. The registered listener will receive all user frames and control frames sent from the client. Also, when the frame is closed or when an unexpected error occurs the listener is notified. Any number of listeners can be registered at any time.- Parameters:
listener
- this is the listener that is to be registered
-
remove
public void remove(FrameListener listener)
This is used to remove aFrameListener
from this instance. After removal the listener will no longer receive any user frames or control messages from this specific instance.- Parameters:
listener
- this is the listener to be removed
-
run
public void run()
This is used to execute the collection operation. Collection is done by reading the frame header from the incoming data, once consumed the remainder of the frame is collected until such time as it has been fully consumed. When consumed it will be dispatched to the registered frame listeners.- Specified by:
run
in interfacejava.lang.Runnable
-
-