-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.ts
62 lines (61 loc) · 1.74 KB
/
models.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
export namespace ServerTypes {
export type Msg = ClientConnectMsg | CreateSessionMsg | UpdateClientMsg | AddClientToSessionMsg | ClientJoinedSessionMsg | ClientLeftSessionMsg | BroadcastToSessionMsg | BroadcastFromSessionMsg | ErrorMsg | InfoMsg
export interface Client {
id: string;
name: string;
lastJoinTime: string;
}
export interface Session {
id: string;
ownerId: string;
clientIds: string[];
}
export interface ClientConnectMsg {
type: "ClientConnect";
client: Client;
}
export interface CreateSessionMsg {
type: "CreateSession";
}
export interface UpdateClientMsg {
type: "UpdateClient";
name: string;
}
export interface AddClientToSessionMsg {
type: "AddClientToSession";
sessionId: string;
addClientId: string;
}
export interface ClientJoinedSessionMsg {
type: "ClientJoinedSession";
clientId: string;
sessionId: string;
sessionOwnerId: string;
clientMap: {[key: string]: Client};
}
export interface ClientLeftSessionMsg {
type: "ClientLeftSession";
clientId: string;
sessionId: string;
sessionOwnerId: string;
clientMap: {[key: string]: Client};
}
export interface BroadcastToSessionMsg {
type: "BroadcastToSession";
payload: string;
}
export interface BroadcastFromSessionMsg {
type: "BroadcastFromSession";
fromSessionOwner: boolean;
senderId: string;
payload: string;
}
export interface ErrorMsg {
type: "Error";
message: string;
}
export interface InfoMsg {
type: "Info";
message: string;
}
}