Server Events - receivers - Usage Details

We’re looking to convert our use of TypeScript handlers with customMessages to receivers.

We have a few questions:

  1. In your examples, you support two levels of receivers e.g

Is this a hard limit of two sublevels, or is also possible?

  1. The third argument is always a URL e.g.
    Can we put other text in the third field? Can it contain spaces?
    Is there a limit to the length of that field?

  2. Is it possible to call addListener() AFTER start() is called?
    There is a removeListener() that appears be callable AFTER start is called?

  3. In the trigger example, you show the use of an object as the third argument.

ServerEvents.NotifyChannel(channel, "trigger.customEvent", new ChatMessage { ... });

is that automatically paired with?

trigger.customEvent {json}
  1. Is this object serialization ew ChatMessage {} available on other methods such as NofifyUser?

Thanks again for this great tool!


The syntax for receivers is fixed to the following format:

{receiver}.{target} {msg}

You could potentially use your own syntax like: msg

Which you should be able to call in your receivers with:

receivers: { 
   "watch/x/y": function(msg) { ...}

Which you create a helper that walks an object graph and returns a flat structure with your chose syntax for its name, e.g. turning the below object graph into the one above:

receivers : myReceivers({
    tv: {
        watch: {
            x: {
                y: function(msg) { .. }

The msg is sent and parsed as json, so if you send a string it’s serialized as a quoted JSON string “msg” it will get parsed as a js msg JS string which your receiver is called with, if you send a complex object, it’s serialized as JSON and deserialized into a JS literal that your receiver is called with instead.


Yes all IServerEvents notification APIs have object message bodies that are sent as JSON and parsed as JSON into a JS data structure.