-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
29 lines (24 loc) · 731 Bytes
/
index.ts
File metadata and controls
29 lines (24 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as express from 'express';
import * as http from 'http';
import { Server } from 'socket.io';
import { listen } from './src/websocket/game/initialization';
const app = express();
const server = http.createServer(app);
const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"]
}
});
io.on('connection', (socket) => {
listen(socket);
});
io.on('disconnect', (socket) => {
console.log("todo: end or disconnect or whatever. transferOperatorOrEnd???");
});
app.use(express.static('public'))
const port = process.env["PORT"] || "3000";
const host = process.env["HOST"] || "localhost";
server.listen(port, () => {
console.log(`Listening on http://${host}:${port}`);
});