Package org.atmosphere.client
Class TrackMessageSizeFilter
java.lang.Object
org.atmosphere.client.TrackMessageSizeFilter
- All Implemented Interfaces:
BroadcastFilter,PerRequestBroadcastFilter
A
PerRequestBroadcastFilter implementation that add the expected length of the message. This is
useful when used with the atmosphere.js library as the library will read the expected size and wait for the
entire messages to be received before invoking its associated callback.
NOTE: The broadcasted message MUST BE a String. If your application is broadcasting another object, you need to
write your own Filter.
If you aren't using atmosphere.js, you need to add the HeaderConfig.X_ATMOSPHERE_TRACKMESSAGESIZE header in order to
enable that Filter. The delimiter character used is '|'.
For example, broadcasting String 'helloword' will be received by the client as '9|helloword' but delivered as 'helloword'
to the Javascript function/callback.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.atmosphere.cpr.BroadcastFilter
BroadcastFilter.BroadcastAction -
Field Summary
Fields inherited from interface org.atmosphere.cpr.BroadcastFilter
VOID_ATMOSPHERE_RESOURCE_UUID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTransform or filter a message.filter(String broadcasterId, AtmosphereResource r, Object originalMessage, Object message) Transform or filter a message perAtmosphereResource.
-
Constructor Details
-
TrackMessageSizeFilter
public TrackMessageSizeFilter()
-
-
Method Details
-
filter
public BroadcastFilter.BroadcastAction filter(String broadcasterId, AtmosphereResource r, Object originalMessage, Object message) Description copied from interface:PerRequestBroadcastFilterTransform or filter a message perAtmosphereResource. Be careful when setting headers on theAtmosphereResponseas the headers may have been already sent back to the browser.- Specified by:
filterin interfacePerRequestBroadcastFilter- Parameters:
broadcasterId- theBroadcaster.getID()r- theAtmosphereResourceoriginalMessage- The original message used when callingBroadcaster.broadcast(Object)message- a message- Returns:
- a
BroadcastFilter.BroadcastAction
-
filter
public BroadcastFilter.BroadcastAction filter(String broadcasterId, Object originalMessage, Object message) Description copied from interface:BroadcastFilterTransform or filter a message. Return BroadcastAction(ACTION.ABORT, message)Broadcasterto discard the message, eg. to not broadcast it.- Specified by:
filterin interfaceBroadcastFilter- Parameters:
broadcasterId- theBroadcaster.getID()calling this objectoriginalMessage- The original message which wasBroadcaster.broadcast(Object);message- The transformed or not message.- Returns:
- a transformed message.
-