The notifyregister is kinda broken, the events are sent twice.
This was tested on Linux amd64 server 3.0.11.1 and server 3.0.11.3.
When you notifyregister on all channels: servernotifyregister event=channel id=0
You get 2 notification with the same values:
Code:
notifyclientmoved ctid=1 reasonid=0 clid=1
notifyclientmoved ctid=1 reasonid=0 clid=1
notifyclientmoved ctid=24 reasonid=0 clid=1
notifyclientmoved ctid=24 reasonid=0 clid=1
When you register on one channel, this happens, the correct behavior:
Code:
servernotifyregister event=channel id=24
error id=0 msg=ok
notifyclientmoved ctid=24 reasonid=0 clid=1 //Client ID 1 switched to channel ID 24
notifyclientmoved ctid=25 reasonid=0 clid=1 //Client ID 1 switched to channel ID 25
You can see the notifcation only being sent once.
This brings us to another "bug", you can only notifyregister on 1 channel.
Code:
servernotifyregister event=channel id=24
error id=0 msg=ok
servernotifyregister event=channel id=25
error id=0 msg=ok
Both times the query response was OK.
But if the user switches from channel ID 1 to channel ID 25, nothing happens. Only the first notifyregister on a channel is being processed.
It would be awesome if this can be fixed: Messages being sent double when notifyregister on channel id=0 and being able to notifyregister on multiple channels at once.
Suggestion
Also the best implementation I can think of is using a channel to id(ctid) and a channel from id(cfid).
For example:
Code:
servernotifyregister event=channel id=24
error id=0 msg=ok
notifyclientmoved ctid=24 cfid=25 reasonid=0 clid=1 //Client ID 1 switched to channel ID 24 from channel ID 25.
notifyclientmoved ctid=25 cfid=24 reasonid=0 clid=1 //And back again.
This is used in the event "notifycliententerview" and "notifyclientleftview" which is triggered if the client connects or disconnect from the channel that is registered.
Which is rather odd because no notifyclientmoved is triggered. What would make it more consistent.