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