-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.cs
29 lines (23 loc) · 875 Bytes
/
example.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Threading;
using WebsocketCollab;
const string WS_URL = "<url>";
const string USER = "<user>";
const string PASS = "<pass>";
const string CHANNEL_ID = "<channel id>";
WebsocketCollabClient wcc = new WebsocketCollabClient();
await wcc.Connect(WS_URL, CHANNEL_ID, USER, PASS);
// Called when a message destined to you, and that you did not send is received by the client.
wcc.OnTextMessage += (s, msg) =>
{
Console.WriteLine($"From: '{msg.Payload.Name}' Message: '{msg.Payload.Content}'");
};
// Called with every message, even those you sent or those that are not destined to you. Additional checks may be required.
wcc.OnAllMessages += (s, msg) =>
{
Console.WriteLine($"From: '{msg.Payload.Name}' Message: '{msg.Payload.Content}'");
};
while (true)
{
Thread.Sleep(2000);
await wcc.SendText("Hilda", "This is a test message", ["all"]);
};