org.atmosphere.client
Class TrackMessageSizeFilter

java.lang.Object
  extended by 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 aren't using atmosphere.js, you need to add the HeaderConfig.X_ATMOSPHERE_TRACKMESSAGESIZE header in order to enable that Filter. The delimiter char 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
TrackMessageSizeFilter()
           
 
Method Summary
 BroadcastFilter.BroadcastAction filter(AtmosphereResource r, Object originalMessage, Object message)
          Transform or Filter a message per request, with V as an indicator.
 BroadcastFilter.BroadcastAction filter(Object originalMessage, Object message)
          Transform or Filter a message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrackMessageSizeFilter

public TrackMessageSizeFilter()
Method Detail

filter

public BroadcastFilter.BroadcastAction filter(AtmosphereResource r,
                                              Object originalMessage,
                                              Object message)
Description copied from interface: PerRequestBroadcastFilter
Transform or Filter a message per request, with V as an indicator. 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
message - Object a message
Returns:
a transformed message.

filter

public BroadcastFilter.BroadcastAction filter(Object originalMessage,
                                              Object message)
Description copied from interface: BroadcastFilter
Transform or Filter a message. Return BroadcastAction(ACTION.ABORT, message) Broadcaster to discard the message, e.g to not broadcast it.

Specified by:
filter in interface BroadcastFilter
Parameters:
originalMessage - The original message which was Broadcaster.broadcast(Object);
message - The transformed or not message.
Returns:
a transformed message.


Copyright © 2013. All Rights Reserved.