org.atmosphere.client
Class TrackMessageSizeFilter
java.lang.Object
org.atmosphere.client.TrackMessageSizeFilter
- All Implemented Interfaces:
- BroadcastFilter, PerRequestBroadcastFilter
public class TrackMessageSizeFilter
- extends Object
- implements 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.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TrackMessageSizeFilter
public TrackMessageSizeFilter()
filter
public BroadcastFilter.BroadcastAction filter(String broadcasterId,
AtmosphereResource r,
Object originalMessage,
Object message)
- Description copied from interface:
PerRequestBroadcastFilter
- Transform or filter a message per
AtmosphereResource. Be careful when setting headers on the
AtmosphereResponse as the headers may have been already sent back to the browser.
- Specified by:
filter in interface PerRequestBroadcastFilter
- Parameters:
broadcasterId - the Broadcaster.getID()r - the AtmosphereResourceoriginalMessage - The original message used when calling Broadcaster.broadcast(Object)message - a message
- Returns:
- a
BroadcastAction
filter
public BroadcastFilter.BroadcastAction filter(String broadcasterId,
Object originalMessage,
Object message)
- Description copied from interface:
BroadcastFilter
- Transform or filter a message. Return BroadcastAction(ACTION.ABORT, message)
Broadcaster to discard the message, eg. to not broadcast it.
- Specified by:
filter in interface BroadcastFilter
- Parameters:
broadcasterId - the Broadcaster.getID() calling this objectoriginalMessage - The original message which was Broadcaster.broadcast(Object);message - The transformed or not message.
- Returns:
- a transformed message.
Copyright © 2014. All Rights Reserved.