-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (26 loc) · 961 Bytes
/
server.js
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
30
31
32
33
34
35
// server.js
// where your node app starts
const http = require("http");
// const https = require("https"),
// fs = require("fs");
// const options = {
// key: fs.readFileSync("/etc/letsencrypt/live/perquackey.davidhoare.net/privkey.pem"),
// cert: fs.readFileSync("/etc/letsencrypt/live/perquackey.davidhoare.net/fullchain.pem")
// };
const express = require("express");
const app = express();
const colyseus = require("colyseus");
const gameRoom = require("./rooms/gameRoom"); // basic starter code
// make all the files in 'public' available
app.use(express.static("public"));
// const server = https.createServer(options, app);
const server = http.createServer(app);
const gameServer = new colyseus.Server({
server,
});
gameServer
.define('mygame', gameRoom.myGameRoom, { maxPlayers: 2 })
.filterBy(['session'])
process.env.PORT = "3100"
gameServer.listen(process.env.PORT);
console.log('Listening on port:' + process.env.PORT);