Join channels

Requires App Context

To set up and manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.

Join() connects a user to a given channel and sets membership by creating a new Membership object that holds the user-channel relationship. This way, the chat user can both watch the channel's content and be its full-fledged member.

After joining, the OnMessageReceived event is triggered when a message is received. You must handle the event to receive the message.

Method signature

This method has the following signature:

channel.Join()

Event signature

public event Action<Message> OnMessageReceived;

Event handler signature

void EventHandler(Message message)
ParameterTypeRequiredDefaultDescription
messageMessageYesn/aThe received message.

Output

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

Basic usage

Join the support channel.

// reference the "channel" object
if (!chat.TryGetChannel("support", out var channel))
{
Console.WriteLine("Couldn't find channel!");
return;
};

channel.OnMessageReceived += OnMessageReceivedHandler; // or use lambda

void OnMessageReceivedHandler(Message message)
{
Console.WriteLine($"Message received: {message.Text}");
}

// join the channel and add metadata to the newly created membership
show all 16 lines
Last updated on