[ejabberd] Offline messages and priority

Raoul Duke rduke496 at gmail.com
Sun Feb 8 06:22:18 MSK 2015


Hi,

I have a situation where a given username has 2 different
sessions/connections (under different resource ids).  Lets call them
sessions A and B (I won't go into the reasons for this  but lets say
it is for "historical reasons")

I would like one of those sessions (B) to never receive any messages
and particularly not offline (mod offline) messages queued for the
associated username.

The reason I particularly mention offline messages is because in
normal operation messages are sent explicitly to the resource id of
session A and so on they basis they can never get delivered to B.
However, it seems that offline messages are queued against the
username rather than the resource and so both A and B have a race
condition over which can collect the queued offline messages
(depending on which of them connects first).  However,I don't want
that.  I always want A to collect the offline messages (never B).

Am I correct in thinking that setting a negative priority on Bs
session will accomplish that goal?

That was my assumption (although correct me if I'm wrong) but I still
have the race condition (although seemingly less often).  Assuming I
am correct then I was wondering if there was a further race condition
in setting the priority.  i.e. could there be a race condition between
B connecting and B asking ejabberd to set a negative priority for the
current session which could mean that B could collect the offline
messages in the meantime?   If so then I was wondering if there was
some way to set an implicit priority for a given user such that it is
enforced atomically when they login so the imagined race condition
wouldn't be possible?

More generally - is there some other way (other than setting negative
priority) to stop a given client session from receiving any messages
from ejabberd?

I am prepared to write a plugin if needs be.   I was looking at the
hooks documentation and noticed that there is a hook called
resend_offline_messages_hook but I don't see how that would help me as
it seems to be user oriented.  In my case the resource ids of A and B
are predictable/known so I was thinking if it would be possible to
"lie" about there being any offline messages for resource id of B then
I would avoid the problem altogether.

BTW - I may be missing something basic/simple in all this and if so
please feel free to suggest another road I can go down.

All help/suggestions appreciated.

Thanks.


More information about the ejabberd mailing list