// 初始化
CloudChat nc = CloudChat.GetInstance();
await nc.initialize([PROJECT_ID]);
nc.dispatcher.onMessageReceived += e =>
{
Console.WriteLine("received a new message: ", e);
};
await nc.Connect(
userId: 'guest@company',
name: 'Guest',
profile: 'https://image_url',
customField: 'json',
);
// 创建频道
var channel = await nc.createChannel(new CloudChatSDK.Channel
{
name = "New Channel",
type = "PUBLIC", // PUBLIC or PRIVATE
customField = "customField"
});
var channel = await nc.createChannel({type:'PUBLIC', name:'First Channel', customField:'customField'});
var channel_id = channel.createChannel.channel.id.ToString();
// 订阅频道
await nc.subscribe(channel_id);
// 发送消息
var response = await nc.sendMessage(
channelId: channel_id,
type:"text",
content: message
);