Class FrameCollector
java.lang.Object
org.simpleframework.http.socket.service.FrameCollector
The
FrameCollector
operation is used to collect frames
from a channel and dispatch them to a FrameListener
.
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
FieldsModifier and TypeFieldDescriptionprivate final Channel
This is the underlying channel for this frame collector.private final ByteCursor
This is the cursor used to maintain a stream seek position.private final FrameProcessor
This decodes the frame bytes from the channel and processes it.private final Reactor
This is the reactor used to schedule this operation for reads.private final Trace
This is the tracer that is used to trace the frame collection. -
Constructor Summary
ConstructorsConstructorDescriptionFrameCollector
(FrameEncoder encoder, Session session, Request request, Reactor reactor) Constructor for theFrameCollector
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
This is called when a read operation has timed out.This is the channel associated with this collector.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 Details
-
processor
This decodes the frame bytes from the channel and processes it. -
cursor
This is the cursor used to maintain a stream seek position. -
channel
This is the underlying channel for this frame collector. -
reactor
This is the reactor used to schedule this operation for reads. -
trace
This is the tracer that is used to trace the frame collection.
-
-
Constructor Details
-
FrameCollector
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 sessionreactor
- this is the reactor used for read notificationschannel
- this is the underlying TCP communication channel
-
-
Method Details
-
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
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
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
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. -
cancel
public void cancel()This is called when a read operation has timed out. To ensure that stale channels do not remain registered they are cleared out with this method and a close frame is sent if possible.
-