public class TrackMessageSizeFilter extends Object implements PerRequestBroadcastFilter
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.BroadcastFilter.BroadcastAction
VOID_ATMOSPHERE_RESOURCE_UUID
Constructor and Description |
---|
TrackMessageSizeFilter() |
Modifier and Type | Method and Description |
---|---|
BroadcastFilter.BroadcastAction |
filter(String broadcasterId,
AtmosphereResource r,
Object originalMessage,
Object message)
Transform or filter a message per
AtmosphereResource . |
BroadcastFilter.BroadcastAction |
filter(String broadcasterId,
Object originalMessage,
Object message)
Transform or filter a message.
|
public BroadcastFilter.BroadcastAction filter(String broadcasterId, AtmosphereResource r, Object originalMessage, Object message)
PerRequestBroadcastFilter
AtmosphereResource
. Be careful when setting headers on the
AtmosphereResponse
as the headers may have been already sent back to the browser.filter
in interface PerRequestBroadcastFilter
broadcasterId
- the Broadcaster.getID()
r
- the AtmosphereResource
originalMessage
- The original message used when calling Broadcaster.broadcast(Object)
message
- a messageBroadcastAction
public BroadcastFilter.BroadcastAction filter(String broadcasterId, Object originalMessage, Object message)
BroadcastFilter
Broadcaster
to discard the message, eg. to not broadcast it.filter
in interface BroadcastFilter
broadcasterId
- the Broadcaster.getID()
calling this objectoriginalMessage
- The original message which was Broadcaster.broadcast(Object)
;message
- The transformed or not message.Copyright © 2016. All rights reserved.