Intial websocket server creation
This commit is contained in:
parent
5b487b2530
commit
8e95c14b6a
2 changed files with 42 additions and 0 deletions
25
server/src/websocket.ts
Normal file
25
server/src/websocket.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { log } from "./main";
|
||||
import { Server, Socket } from "socket.io";
|
||||
|
||||
import CreateGame from "./events/CreateGame";
|
||||
|
||||
|
||||
export default async (conf: config) => {
|
||||
|
||||
const io = new Server();
|
||||
|
||||
io.listen(conf.websocket.port, {
|
||||
cors: {
|
||||
origin: conf.webserver.hostname,
|
||||
credentials: true,
|
||||
}
|
||||
})
|
||||
|
||||
io.on(`connection`, (socket: Socket) => {
|
||||
log.debug(`Client connected with ID: ${socket.id}`);
|
||||
|
||||
socket.on(`CreateGame`, (data: CreateGame) => CreateGame(io, socket, data));
|
||||
});
|
||||
|
||||
log.info(`Server started on port ${conf.websocket.port}`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue