Channel

Channel

In Game Chat, the channel is a virtual space where users can communicate in a group. Through channels, you can share information suitable for a specific subject or purpose, enhance teamwork, and systematize communication. Channel is a useful tool to increase business efficiency, and centralize and manage communication in a specific group. The following describes the channel functions of Game Chat.

Main functions of channel

  1. Group communication: you can create a channel and communicate with members in a specific group. It is suitable for diverse forms of groups, such as project teams, divisions, or clubs.

  2. Message and file sharing: you can easily share various forms of files such as text messages, images, videos, and documents in the channel.

  3. Real-time update: all activities in the channel are updated in real time so that every participant can obtain the latest information.

  4. Admin control: the creator or admin of the channel has the right to change channel settings or add and remove users.

  5. Calls and video conferencing function: some channels provide voice calls or video conferencing for effective communication between members.

  6. Notification settings: you can set notifications by channel so as not to miss important messages.

  7. Search features: you can easily search dialogs or files in the channel, so you can quickly find the information you need.

Manage channel

  • Create channel: you can create a new channel suitable for your purpose and set information such as channel name, descriptions, and members.

  • Channel invitation: the admin of the channel can invite other users to the channel. The user who is invited can accept or decline the invitation.

  • Manage members: the admin can set the permissions of the channel members or remove members from the channel.

Security

  • Data security: all data in the channel are encrypted and transmitted, and are stored safely in the server.

  • Personal information protection: the information shared in the channel can be accessed only among channel members and is protected against leak to the outside.

When you use the channel function of Game Chat, you can enjoy easy communication within the organization and among individuals, and manage information effectively. These features are very useful when you manage large-scale organizations or various projects.

Create channel

All conversations require you to create channels and participate in the channel to chat normally. The following guides you on how to create and subscribe to channels.

await nc.createChannel(new NBaseSDK.Channel
{
    name = "New Channel",
    type =[TYPE],    // PUBLIC or PRIVATE
    customField = [CustomField]
});
IDTypeDescriptionRequired

NAME

string

Channel name

O

TYPE

string

Channel type (PUBLIC or PRIVATE)

O

UniqueID

string

Unique ID

X

push

boolean

Push notification status

X

linkUrl

string

Link status

X

imageUrl

string

Link status

X

integrationId

string

Integration feature (translation, voice, etc.)

X

disabled

string

Channel use status

X

members

array

ID allowed to join if PRIVATE

X

CustomField

string

User-defined field, can be put as a JSON String for more versatility

X

Note

  • For security, create a channel through the server instead of creating a channel on the client side.

Subscribe to channel

Subscribe to the desired channel (join the room). Once you join a channel, you will join automatically when you access it again until you unsubscribe from it.

Hashtable option = new Hashtable
{
    { "language", "en" }    // You can add more options besides the ones required for automatic translation.
};
await nc.subscribe([CHANNEL_ID], option);

Unsubscribe from channels

Unsubscribe from the channel. You will no longer receive messages from this channel.

await nc.unsubscribe([CHANNEL_ID]);

Participant list

You can import the participant list (for a specific channel).

Hashtable filter = new Hashtable
{
    { "channel_id", channelId }
};
Hashtable sort = new Hashtable
{
    { "created_at", -1 }
};
Hashtable option = new Hashtable
{
    { "offset", 0 },
    { "per_page", 10 }
};
var subscriptions = await nc.getSubscriptions(filter, sort, option);
foreach (var subscription in subscriptions.edges)
{
    string id = subscription.node.id.ToString();
    Console.WriteLine("[CloudChatSample] id={0}", id);
}
  • Parameters

IDTypeDescription

filter

object

Search is available for all fields of a query through filtering

sort

object

Define the filter for the fields you want to sort (ascending order "1", descending order "-1")

option

object

See the following when there are options

  • Options

IDTypeDescription

offset

number

Start offset

per_page

number

The number of returns (up to 100)

Advanced

To import only a list of online users accessing a specific channel, add "online" as "true" to the filter.

Hashtable filter = new Hashtable
{
    { "channel_id", [CHANNEL_ID] },
    { "online" , true}
};
Hashtable sort = new Hashtable
{
    { "created_at", -1 }
};
Hashtable option = new Hashtable
{
    { "offset", 0 },
    { "per_page", 10 }
};

var subscriptions = await nc.getSubscriptions(filter, sort, option);

Subscribe to channel

  • Subscription Data Class

IDTypeDescription

id

string

Unique ID

channel_id

string

Channel ID

user_id

string

Unique ID of the user

created_at

string

Creation date

online

boolean

Whether the user is online

push

boolean

Whether the user allows push notifications

language

string

Language

channel

string

Channel information

mark.user_id

string

User who sent the last message

mark.message_id

string

ID of the last message

mark.sort_id

string

Last message sort ID

mark.unread

string

Number of unread messages since the last message

Channel information

  • Channel Data Class

IDTypeDescription

id

string

Channel ID (unique)

project_id

string

Project ID

unique_id

string

Channel ID that can be set by the developer (unique)

name

string

Channel name

user_id

string

User ID (that created the channel)

unique_id

string

Unique ID of channel

default_lang

string

Default language

lang

string

The language of the current user

members

string

If private, the list of participating users

last_message

array

See the last message information [MessageType]

push

boolean

Whether push messages are supported (if the channel is private)

state

boolean

Channel status

customField

string

User-defined data

created_at

string

Creation date

updated_at

string

Renewal date

Import channel data

Use the following code to import the channel data of a project in the form of a list.

Hashtable filter = new Hashtable
{
    { "state", true }
};
Hashtable sort = new Hashtable
{
    { "created_at", -1 }
};
Hashtable option = new Hashtable
{
    { "offset", 0 },
    { "per_page", 10 }
};
var channels = await nc.getChannels(filter,sort,option);
foreach (var channel in channels.edges)
{
    string id = channel.node.id.ToString();
    Console.WriteLine("[CloudChatSample] id={0}", id);
}
  • Parameters

IDTypeDescriptionRequired

filter

object

Search is available for all fields of a query through filtering

O

sort

object

Define a filter for the fields you want to sort

X

option

object

See the following when there are options

X

  • Options

IDTypeDescription

offset

number

Start offset

per_page

number

The number of returns (up to 100)

Individual channel

  • You can get information about individual channels.

Channel channel = await nc.getChannel(id);

Invite user to channel

Invite a user to participate when the channel is private.

await nc.addUsers(newChannelId, new string[] { "ID", "ID" });

Delete user from channel

Delete a user who is a participant when the channel is private.

await nc.removeUsers(channelId, new string[] { "ID", "ID" });

Block user from channel

Block a user within a channel. It can only be used by users who have permission to create a channel, or admin with full access.

Hashtable option = new Hashtable
{
    { "timeout", [endtime(seconds)] },
    { "reason", [reason for blocking] }
};
await nc.banUser(channelId, userId, options);
  • Options Data Class

IDTypeDescription

timeout

string

Block time (seconds)

reason

string

Cause of blocking

Unblock user from channel

Unblock the blocked person within the channel. It can only be used by users who have permission to create a channel, or admin with full access.

await nc.unbanUser(channelId, userId);

Delete channel

Delete the corresponding channel (you can delete 1 channel or multiple channels).

Channel channel = await nc.deleteChannel([CHANNEL_ID]);

Edit channel

Update the channel information.

Channel channel = await nc.updateChannel([CHANNEL_ID],Channel);

Last updated