forked from jamesshore/lets_code_javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (19 loc) · 799 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (19 loc) · 799 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
// Copyright (c) 2012-2017 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
(function() {
"use strict";
const HttpServer = require("./http_server.js");
const RealTimeServer = require("./real_time_server.js");
module.exports = class Server {
async start(contentDir, notFoundPageToServe, portNumber) {
if (!portNumber) throw new Error("port number is required");
this._httpServer = new HttpServer(contentDir, notFoundPageToServe);
await this._httpServer.start(portNumber);
this._realTimeServer = new RealTimeServer();
this._realTimeServer.start(this._httpServer.getNodeServer());
}
async stop() {
if (this._realTimeServer === undefined) throw new Error("stop() called before server started");
await this._realTimeServer.stop();
}
};
}());