Watch / Unwatch channels

You can let users watch a given channel and its messages, without the need to join the channel as members. Similarly, you can stop watching the channel without the need to leave the channel.

Watch a channel

Connect() lets users watch a given channel and its messages. After connecting, the OnMessageReceived event is triggered when a message is received. You must handle the event to receive the message.

Method signature

1channel.Connect()

Event signature

1public event Action<Message> OnMessageReceived;

Event handler signature

1void EventHandler(Message message)
* required
ParameterDescription
message *
Type: Message
Default:
n/a
The received message.

Output

This method doesn't return anything. To receive a message, you must handle the OnMessageReceived event.

Sample code

Start receiving messages on the support channel.

1

Unwatch a channel

Disconnect() lets users unwatch a given channel and its messages.

Method signature

1channel.Disconnect()

Output

This method doesn't return anything.

Sample code

Stop receiving messages from a channel after receiving the first message.

1

Last updated on