For AI agents: this page in Markdown: https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/channel.md. Documentation index: https://www.pubnub.com/llms-full.txt.
Channel object
The Channel object represents a single chat room where users can send and receive messages.
Properties
The Channel object has the following properties:
1public class Channel : UniqueChatEntity {
2 public string Id { get; protected set; }
3 public string Name { get; }
4 public string Description { get; }
5 public Dictionary<string, object> CustomData { get; }
6 public string Updated { get; }
7 public string Status { get; }
8 public string Type { get; }
9}
Name#- Display name or title of the channel.
Description#- Brief description or summary of the channel's purpose or content.
CustomData#- Custom data associated with the channel in the form of a JSON. Values must be scalar only; arrays or objects are not supported. App Context filtering language doesn’t support filtering by custom properties.
Updated#- Timestamp indicating when the channel was last updated or modified.
Status#- Current status of the channel, such as
online,offline, orarchived. Type#- One of the available channel types:
direct(1:1)group(multiple people, restricted by invitation)public(open chat for a large audience, anyone can join it)
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
Events
The Channel object has the following events:
1// Event triggered when a message is received on a channel.
2// Call Connect(true) to enable this callback.
3public event Action<Message> OnMessageReceived;
4// Event triggered when a channel is updated.
5// Call StreamUpdates(true) to enable this callback.
6public event Action<Channel> OnUpdated;
7// Event triggered when a channel is hard-deleted from App Context.
8// Call StreamUpdates(true) to enable this callback.
9public event Action OnDeleted;
10// Event triggered when a presence state changes on a channel.
11// Call StreamPresence(true) to enable this callback.
12public event Action<List<string>> OnPresenceUpdate;
13// Event triggered when typing is detected on a channel.
14// Call StreamTyping(true) to enable this callback.
15public event Action<List<string>> OnUsersTyping;
show all 24 linesExample
An event that is triggered when a new message is received on a channel.
1
Methods
You can call the following methods on the Channel object.
Click on each method for more details.
Standard methods
Connect()CreateMessageDraft()Delete()DeleteFile()Disconnect()EmitCustomEvent()ForwardMessage()GetFiles()GetInvitees()GetMember()GetMemberships()GetMessage()GetMessageHistory()GetPinnedMessage()GetReadReceipts()GetUserRestrictions()GetUsersRestrictions()HasMember()Invite()InviteMultiple()IsUserPresent()JoinChannel()LeaveChannel()PinMessage()RegisterForPush()SendText()SetRestrictions()StartTyping()StopTyping()UnpinMessage()UnRegisterFromPush()Update()WhoIsPresent()
Streaming methods
These methods register or unregister real-time event subscriptions. Each streaming method activates one or more of the events listed in the Events section above.
StreamCustomEvents()StreamPresence()StreamReadReceipts()StreamReportEvents()StreamTyping()StreamUpdates()StreamUpdatesOn()
Use case
For example, you can use the Channel object methods to:
- Let users send messages.
- Create and manage a 1:1, group, or public channel (chat).
- Invite others to join the channel.
- Check if a user is a member of the channel.
- Configure a typing indicator to track when someone in the room is writing a message.