Class WebSocketDemander
- All Implemented Interfaces:
 Callback, Invocable, DemandChain
This flusher can be used to mutated and fragment Frames and forwarded them on towards the application using the
IncomingFrames provided in the constructor. This can split a single incoming frame into n Frames which are
passed on to the IncomingFrames one at a time.
The asynchronous operation performed by this IteratingCallback is demanding from upper layer after which
onFrame(Frame, Callback) will called with the new content.
This flusher relies on the interception of demand, and because of this it can only be used in an Extension which
implements the DemandChain interface. The methods of DemandChain from the Extension
must be forwarded to this flusher.
- 
Nested Class Summary
Nested classes/interfaces inherited from class IteratingCallback
IteratingCallback.ActionNested classes/interfaces inherited from interface Callback
Callback.Combination, Callback.Completable, Callback.Completing, Callback.NestedNested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task - 
Field Summary
Fields inherited from interface Callback
NOOP, NOT_CALLEDFields inherited from interface Invocable
__nonBlocking - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidUsed to close this flusher when there is no explicit failure.voiddemand()This is demand is called by the application to demand a new frame to be processed inhandle(Frame, Callback, boolean).voidThis is used within an implementation ofhandle(Frame, Callback, boolean)to forward a frame onto the next layer of processing.voidUsed to fail this flusher possibly from an external event such as a callback.protected abstract booleanCalled when there is demand for a single frame to be produced.protected voidonCompleteFailure(Throwable cause) Invoked when the overall task has completed with a failure.voidUsed to supply the flusher with a new frame.protected IteratingCallback.Actionprocess()Method called byIteratingCallback.iterate()to process the asynchronous sub-task.voidsetNextDemand(DemandChain nextDemand) Set the nextDemandChaininstance towards the transport side of theDemandChainpipeline.Methods inherited from class IteratingCallback
abort, close, failed, isAborted, isClosed, isFailed, isSucceeded, iterate, onAborted, onCompleted, onCompleteSuccess, onFailure, onSuccess, reset, succeeded, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Callback
completeWith 
- 
Constructor Details
- 
WebSocketDemander
- Parameters:
 emitFrame- where frames generated byhandle(Frame, Callback, boolean)are forwarded.
 
 - 
 - 
Method Details
- 
setNextDemand
Description copied from interface:DemandChainSet the nextDemandChaininstance towards the transport side of theDemandChainpipeline.- Specified by:
 setNextDemandin interfaceDemandChain- Parameters:
 nextDemand- the next link in the demand chain.
 - 
handle
Called when there is demand for a single frame to be produced. During this method a single call can be made to
emitFrame(Frame, Callback)which will forward this frame towards the application. Returning true from this method signals that you are done processing the current Frame, and the next invocation of this method will have the next frame.Note that the callback supplied here is specially wrapped so that you can call it multiple times, and it will not be completed more than once. This simplifies the handling of failure cases.
- Parameters:
 frame- the original frame.callback- to succeed to release the frame payload.first- if this is the first time this method has been called for this frame.- Returns:
 - false to continue processing this frame, true to complete processing and get a new frame.
 
 - 
emitFrame
This is used within an implementation of
handle(Frame, Callback, boolean)to forward a frame onto the next layer of processing.This method should only be called ONCE within each invocation of
handle(Frame, Callback, boolean)otherwise- Parameters:
 frame- the WebSocket frame.callback- to release frame payload.
 - 
demand
public void demand()This is demand is called by the application to demand a new frame to be processed inhandle(Frame, Callback, boolean).- Specified by:
 demandin interfaceDemandChain
 - 
onFrame
Used to supply the flusher with a new frame. This frame should only arrive if demanded through theDemandChainprovided bysetNextDemand(DemandChain).- Parameters:
 frame- the WebSocket frame.callback- to release frame payload.
 - 
closeFlusher
public void closeFlusher()Used to close this flusher when there is no explicit failure. - 
failFlusher
Used to fail this flusher possibly from an external event such as a callback.- Parameters:
 t- the failure.
 - 
process
Description copied from class:IteratingCallbackMethod called byIteratingCallback.iterate()to process the asynchronous sub-task.Implementations must initiate the asynchronous execution of the sub-task (if any) and return an appropriate action:
IteratingCallback.Action.IDLEwhen no sub tasks are available for execution but the overall job is not completed yetIteratingCallback.Action.SCHEDULEDwhen the sub task asynchronous execution has been startedIteratingCallback.Action.SUCCEEDEDwhen the overall job is completed
- Specified by:
 processin classIteratingCallback- Returns:
 - the appropriate Action
 - Throws:
 Throwable- if the sub-task processing throws
 - 
onCompleteFailure
Description copied from class:IteratingCallbackInvoked when the overall task has completed with a failure.Calls to this method are serialized with respect to
IteratingCallback.process(),IteratingCallback.onAborted(Throwable)andIteratingCallback.onCompleted(Throwable). If this method is called, thenIteratingCallback.onCompleteSuccess()will never be called.- Overrides:
 onCompleteFailurein classIteratingCallback- Parameters:
 cause- the throwable to indicate cause of failure- See Also:
 
 - 
getInvocationType
- Specified by:
 getInvocationTypein interfaceInvocable- Returns:
 - The InvocationType of this object
 
 
 -