-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocketClient.ts
36 lines (29 loc) · 1020 Bytes
/
SocketClient.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
import { Server, Socket } from 'socket.io';
import { HydratedDocument } from 'mongoose'
import { UserData } from '../db/schemas/User.model';
export class SocketClient {
// The Socket.IO server object controlled by the parent Server class
io: Server;
// The socket object controlling the client's connection
socket: Socket;
// The user the client has authenticated as
user: HydratedDocument<UserData>;
/**
* Hydrates the client object post-authentication
* @param io The Socket.IO server object controlled by the parent Server class
* @param socket The socket object controlling the client's connection
* @param user The user the client has authenticated as
*/
constructor(io: Server, socket: Socket, user: HydratedDocument<UserData>) {
// Set the client information
this.io = io;
this.socket = socket;
this.user = user;
this.createEventHandlers();
}
/**
* Hooks the event handler methods into Socket.IO's event system
*/
createEventHandlers() {
}
}