Atmosphere/atmosphere — Issue #130: RedisFilter broadcast called twice
Author: vbarrier
Created: 2011-12-19 04:54:46+00:00
State: open

Hello JF,

With the RedisFilter my broadcasted message is sent twice because :

if (!(receivedMessages.remove(contents))) {
jedisPublisher.publish(bc.getID(), contents);
}
return new BroadcastFilter.BroadcastAction(BroadcastAction.ACTION.CONTINUE, o);

trace:

- broadcast called
- broadcast filter -> message not in receivedMessages
- publish
- filter says ACTION.CONTINUE
- message sent
- same broadcast receive the message (onMessage)
- broadcast
- broadcast filter -> message in receivedMessages
- no publish
-> filter says ACTION.CONTINUE
-> message sent (so twice)

Easy fix :

if (!(receivedMessages.remove(contents))) {
jedisPublisher.publish(bc.getID(), contents);
return new BroadcastFilter.BroadcastAction(BroadcastAction.ACTION.CONTINUE, o);
}else{
return new BroadcastFilter.BroadcastAction(BroadcastAction.ACTION.ABORT, o);
}

Or maybe I'm wrong...