add basic socketio to server
This commit is contained in:
parent
45ec6b856a
commit
b29cdae088
8 changed files with 252 additions and 1 deletions
11
src/middleware/checkSocketExists.ts
Normal file
11
src/middleware/checkSocketExists.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { Event, Socket } from "socket.io";
|
||||
import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException";
|
||||
import { SocketMap } from "../storage/socketMap";
|
||||
|
||||
export default async (socket: Socket, [event, ...args]: Event, next: any) => {
|
||||
if (SocketMap.exists(socket.id)) {
|
||||
next();
|
||||
} else {
|
||||
next(new UnauthorizedRequestException("not authorized for connection"));
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue