admin side scan connection
This commit is contained in:
parent
b29cdae088
commit
83ab0c4ea7
7 changed files with 156 additions and 6 deletions
|
@ -1,9 +1,15 @@
|
|||
import helmet from "helmet";
|
||||
import { Server as httpServerType } from "http";
|
||||
import { Server } from "socket.io";
|
||||
import { instrument } from "@socket.io/admin-ui";
|
||||
|
||||
import authenticateSocket from "../middleware/authenticateSocket";
|
||||
import checkSocketExists from "../middleware/checkSocketExists";
|
||||
import { SocketConnectionTypes } from "../enums/socketEnum";
|
||||
|
||||
import base from "./base";
|
||||
import scanner from "./scanner";
|
||||
import pScanner from "./pScanner";
|
||||
|
||||
export default abstract class SocketServer {
|
||||
private static io: Server;
|
||||
|
@ -17,17 +23,31 @@ export default abstract class SocketServer {
|
|||
},
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV) {
|
||||
instrument(this.io, {
|
||||
auth: false,
|
||||
mode: "development",
|
||||
});
|
||||
}
|
||||
|
||||
this.io.engine.use(helmet());
|
||||
|
||||
this.io
|
||||
.of("/scanner")
|
||||
.of(SocketConnectionTypes.scanner)
|
||||
.use(authenticateSocket)
|
||||
.on("connection", (socket) => {
|
||||
console.log("socket connection: ", socket.id);
|
||||
socket.use((packet, next) => authenticateSocket(socket, next));
|
||||
socket.use((packet, next) => checkSocketExists(socket, packet, next));
|
||||
|
||||
base(this.io, socket);
|
||||
scanner(this.io, socket);
|
||||
});
|
||||
|
||||
this.io.of(SocketConnectionTypes.pscanner).on("connection", (socket) => {
|
||||
console.log("socket connection: ", socket.id);
|
||||
|
||||
base(this.io, socket);
|
||||
pScanner(this.io, socket);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue