-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
33 lines (25 loc) · 906 Bytes
/
index.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
import {Server} from "colyseus";
import {createServer} from "http";
import { AlexaServer } from "./server/alexa/AlexaServer.js";
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import { GameRoom } from './server/multiplayer/rooms/GameRoom.js';
//CHANGE THIS TO YOUR WEB APP URL
const WEB_APP_URL = "https://alexa-phaser-colyseus-demo.herokuapp.com/";
const PORT = process.env.PORT || 8080;
const app = express();
const __dirname = path.dirname(fileURLToPath(import.meta.url));
//SET UP WEB APP
app.use(express.static(__dirname + '/client'));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
//SET UP ALEXA
const alexaServer = new AlexaServer(app, WEB_APP_URL);
//SET UP COLYSEUS SERVER
const gameServer = new Server({
server: createServer(app)
});
gameServer.listen(PORT);
gameServer.define("gameRoom", GameRoom);