ServerEventsClient ServerEventMessage channel always null

Hi,

when I notify an event from the server I use

ServerEvents.NotifySubscription(s.SubscriptionId, "cmd.{0}".Fmt(methodName.ToLower()), entityId, channelName)

then I handle the selector on the client as is

this.serverEvents = new ServerEventsClient(this.endPoint, this.channels, {
            handlers: {
                onMessage: (msg: ServerEventMessage) => {
                    if (callbackMessageFn) {
                        callbackMessageFn.apply(callbackCtx, [msg]); 
                    } ...

but msg.channel is always null, what I’m missing?

What does JSON.stringify(msg) return?

JSON.stringify output is this

{"eventId":4,"data":"cmd.update 6005","type":"ServerEventMessage","channel":null,"selector":"cmd.update","json":"6005","body":6005,"op":"cmd","target":"update","meta":{}}

more details in this png

the png is about the onMessage handler, I’m using the custom selector update but channel is always null there as in onMessage handler

Yeah the channel doesn’t get sent with the notification, just the selector and message body. The channel controls whether the subscriber gets the message at all based on whether they’re subscribed to the channel.

Please let me know.
In my application the client subscribes a list of channels, the server sends notification for a single channel then for another single channel and so on.
From the client side I hoped to get the channel notified in the ServerEventMessage channel property.
Now, the channel property is null because the server sends the selector?

It’s null because the channel isn’t sent. Add any additional metadata you need in your message body.

The server sends the channel, this is the code

ServerEvents.NotifySubscription(s.SubscriptionId, "cmd.{0}".Fmt(methodName.ToLower()), entityId, channelName)

the var channelName contains the channel I expect to see on client.
What is the purpouse of the property channel in ServerEventMessage?

Like I said, the channel is used to filter the message, it isn’t sent on the wire.

Yes I understand.
Maybe the property channel in ServerEventMessage has another purpouse, maybe I can change my design.