import socketIo,{Socket} from "socket.io"; import {Server} from "http"; import {Keys} from "@onebro/oba-common"; import {OBAExpressApiSocketsConfigType} from "./sockets-types"; export type OBAExpressApiSocketsConfig = OBAExpressApiSocketsConfigType; export class OBAExpressApiSockets { static init = (config:OBAExpressApiSocketsConfig,httpServer:Server) => { const io = new socketIo.Server(httpServer); io.on("connection",(s:Socket) => {for(const k in config) s.on(k,config[k as Keys](io,s));}); return io; } } export default OBAExpressApiSockets;