forked from Willen17/chatroom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
65 lines (57 loc) · 1.76 KB
/
types.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
63
64
65
export interface ServerToClientEvents {
message: (message: string, from: { id: string; nickname: string }) => void;
sendRoomMessageHistory: (messages: MessageType[]) => void;
connected: (user: User) => void;
roomList: (rooms: ChatRoom[]) => void;
joined: (room: string) => void;
_error: (errorMessage: string) => void;
isTypingIndicator: (nickname: string, privateChat?: boolean) => void;
left: (room: string) => void;
users: (users: User[]) => void;
sendUserID: (userID: string) => void;
privateMessage: (content: string, from: string) => void;
initSession: (session: SessionInterface) => void;
sendPrivateMessageHistory: (messages: DirectMessage[]) => void;
}
export interface ClientToServerEvents {
message: (message: string, to: string) => void;
getRoomMessageHistory: (room: string) => void;
join: (room: string, privateChat?: boolean | undefined) => void;
typing: (room: string, isPrivateChat?: boolean) => void;
leave: (room: string) => void;
getUserID: (username: string) => void;
privateMessage: (content: string, to: string) => void;
getPrivateMessageHistory: (id1: string, id2: string) => void;
}
export interface SessionInterface {
sessionID: string;
userID: string;
nickname: string;
}
export interface InterServerEvents {}
export interface ServerSocketData {
nickname: string;
sessionID: string;
userID: string;
isConnected: boolean;
socketID: string;
}
export interface User {
userID: string;
username: string;
isConnected: boolean;
socketID: string;
messages?: DirectMessage[] | undefined;
}
export interface DirectMessage {
content: string;
from: string;
}
export interface ChatRoom {
name: string;
sockets: ServerSocketData[];
}
export interface MessageType {
message: string;
from: string;
}