middleware error catch
This commit is contained in:
parent
1151ec45dc
commit
3da02a89a7
1 changed files with 37 additions and 33 deletions
|
@ -7,6 +7,7 @@ import { Socket } from "socket.io";
|
||||||
import { SocketMap } from "../../storage/socketMap";
|
import { SocketMap } from "../../storage/socketMap";
|
||||||
|
|
||||||
export default async function authenticateSocket(socket: Socket, next: Function) {
|
export default async function authenticateSocket(socket: Socket, next: Function) {
|
||||||
|
try {
|
||||||
const token = socket.handshake.auth.token;
|
const token = socket.handshake.auth.token;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
@ -45,4 +46,7 @@ export default async function authenticateSocket(socket: Socket, next: Function)
|
||||||
socket.join("home");
|
socket.join("home");
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
} catch (err) {
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue