forked from OrleansContrib/Orleankka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatUser.cs
More file actions
27 lines (22 loc) · 676 Bytes
/
ChatUser.cs
File metadata and controls
27 lines (22 loc) · 676 Bytes
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
using System;
using System.Threading.Tasks;
using Orleankka;
namespace Example
{
public class ChatUser : Actor
{
Task On(Join x) => Send(x.Room, $"{Id} joined the room {x.Room} ...");
Task On(Leave x) => Send(x.Room, $"{Id} left the room {x.Room}!");
Task On(Say x) => Send(x.Room, $"{Id} said: {x.Message}");
Task Send(string room, string message)
{
Console.WriteLine("[server]: " + message);
var stream = System.StreamOf("sms", room);
return stream.Push(new ChatRoomMessage
{
User = Id,
Text = message
});
}
}
}