checkpoint
This commit is contained in:
parent
483389e696
commit
cc694ee5b6
Dockerfile
build
docker-compose.ymlindex.jsmongo-volume
WiredTigerWiredTiger.lockWiredTiger.turtleWiredTiger.wtWiredTigerHS.wt_mdb_catalog.wtcollection-0--7692121742958003173.wtcollection-10--7692121742958003173.wtcollection-2--7692121742958003173.wtcollection-4--7692121742958003173.wtcollection-6--7692121742958003173.wtcollection-8--7692121742958003173.wt
package.jsondiagnostic.data
index-1--7692121742958003173.wtindex-11--7692121742958003173.wtindex-3--7692121742958003173.wtindex-5--7692121742958003173.wtindex-7--7692121742958003173.wtindex-9--7692121742958003173.wtjournal
mongod.locksizeStorer.wtstorage.bsonsounds
.gitignore
Emotional
a-1.mp3a0.mp3a1.mp3a2.mp3a3.mp3a4.mp3a5.mp3a6.mp3as-1.mp3as0.mp3as1.mp3as2.mp3as3.mp3as4.mp3as5.mp3as6.mp3b-1.mp3b0.mp3b1.mp3b2.mp3b3.mp3b4.mp3b5.mp3b6.mp3c0.mp3c1.mp3c2.mp3c3.mp3c4.mp3c5.mp3c6.mp3c7.mp3cs0.mp3cs1.mp3cs2.mp3cs3.mp3cs4.mp3cs5.mp3cs6.mp3d0.mp3d1.mp3d2.mp3d3.mp3d4.mp3d5.mp3d6.mp3ds0.mp3ds1.mp3ds2.mp3ds3.mp3ds4.mp3ds5.mp3ds6.mp3e0.mp3e1.mp3e2.mp3e3.mp3e4.mp3e5.mp3e6.mp3
@ -4,7 +4,6 @@ WORKDIR /usr/src/app
|
||||
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
|
||||
RUN npm install --production --silent && mv node_modules ../
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
RUN chown -R node /usr/src/app
|
||||
USER node
|
||||
CMD ["npm", "start"]
|
||||
|
54
build/Channel.js
Normal file
54
build/Channel.js
Normal file
@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
exports.__esModule = true;
|
||||
exports.Channel = void 0;
|
||||
var stream_1 = require("stream");
|
||||
var Channel = /** @class */ (function (_super) {
|
||||
__extends(Channel, _super);
|
||||
function Channel(server, _id) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.server = server;
|
||||
_this._id = _id;
|
||||
server.channels.set(_this._id, _this);
|
||||
_this.bindEventListeners();
|
||||
return _this;
|
||||
}
|
||||
Channel.prototype.bindEventListeners = function () {
|
||||
this.on('a', function (msg) {
|
||||
});
|
||||
};
|
||||
Channel.prototype.addClient = function (cl) {
|
||||
};
|
||||
Channel.prototype.isLobby = function () {
|
||||
var reg = /^(lobby[0-9].*|test\/([A-z]{1,})|lobby$)/;
|
||||
return reg.test(this._id);
|
||||
};
|
||||
return Channel;
|
||||
}(stream_1.EventEmitter));
|
||||
exports.Channel = Channel;
|
||||
var ChannelSettings = /** @class */ (function () {
|
||||
function ChannelSettings() {
|
||||
}
|
||||
return ChannelSettings;
|
||||
}());
|
||||
var Crown = /** @class */ (function () {
|
||||
function Crown(user_id, partid) {
|
||||
this._id = user_id;
|
||||
this.id = partid;
|
||||
}
|
||||
return Crown;
|
||||
}());
|
188
build/Client.js
Normal file
188
build/Client.js
Normal file
@ -0,0 +1,188 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
exports.__esModule = true;
|
||||
exports.Client = void 0;
|
||||
var stream_1 = require("stream");
|
||||
var Crypto_1 = require("./Crypto");
|
||||
var Database_1 = require("./Database");
|
||||
var Client = /** @class */ (function (_super) {
|
||||
__extends(Client, _super);
|
||||
function Client(server, ws, req, id) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.server = server;
|
||||
_this.participantID = id;
|
||||
var _id = Crypto_1.Crypto.getUser_ID(req.socket.address().address);
|
||||
var user = Database_1.Database.getDefaultUser();
|
||||
user._id = _id;
|
||||
_this.user = user;
|
||||
Database_1.Database.getUser(_id).then(function (val) {
|
||||
_this.user = val;
|
||||
console.log(val);
|
||||
});
|
||||
_this.ws = ws;
|
||||
_this.bindEventListeners();
|
||||
return _this;
|
||||
}
|
||||
Client.prototype.bindEventListeners = function () {
|
||||
var _this = this;
|
||||
this.ws.on('message', function (data, isBinary) {
|
||||
var d = data;
|
||||
if (isBinary) {
|
||||
d = data.toString();
|
||||
}
|
||||
try {
|
||||
var msgs = JSON.parse(d);
|
||||
if (typeof msgs !== 'object')
|
||||
return;
|
||||
for (var _i = 0, msgs_1 = msgs; _i < msgs_1.length; _i++) {
|
||||
var msg = msgs_1[_i];
|
||||
console.log(msg.m);
|
||||
_this.emit(msg.m, msg);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err)
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
this.ws.on('close', function () {
|
||||
_this.emit('bye');
|
||||
});
|
||||
this.once('hi', function (msg) {
|
||||
_this.sendHiMessage();
|
||||
});
|
||||
this.on('bye', function (msg) {
|
||||
console.debug('deleting user ' + _this.participantID);
|
||||
_this.server.destroyClient(_this.participantID);
|
||||
});
|
||||
this.on('ch', function (msg) {
|
||||
});
|
||||
this.on('n', function (msg, admin) {
|
||||
});
|
||||
this.on('m', function (msg, admin) {
|
||||
});
|
||||
this.on('userset', function (msg, admin) {
|
||||
if (!msg.set)
|
||||
return;
|
||||
if (typeof msg.set !== 'object')
|
||||
return;
|
||||
var _idToSet;
|
||||
if (admin) {
|
||||
if (msg.id) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
});
|
||||
this.on('chset', function (msg, admin) {
|
||||
});
|
||||
this.on('admin message', function (msg) {
|
||||
});
|
||||
this.on('subscribe to admin stream', function (msg, admin) {
|
||||
});
|
||||
this.on('user_flag', function (msg, admin) {
|
||||
});
|
||||
};
|
||||
Client.prototype.getOwnParticipant = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, Database_1.Database.getPublicUser(this.user._id)];
|
||||
case 1: // TODO getOwnParticipant
|
||||
return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Client.prototype.sendHiMessage = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a;
|
||||
var _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
console.log('sending hi message');
|
||||
_a = this.sendArray;
|
||||
_b = {
|
||||
m: 'hi',
|
||||
motd: "galvanized saga"
|
||||
};
|
||||
return [4 /*yield*/, this.getOwnParticipant()];
|
||||
case 1:
|
||||
_a.apply(this, [[(_b.u = _c.sent(),
|
||||
_b.v = '3.0',
|
||||
_b)]]);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Client.prototype.sendArray = function (msgarr) {
|
||||
console.log(msgarr);
|
||||
var json = JSON.stringify(msgarr);
|
||||
this.send(json);
|
||||
};
|
||||
Client.prototype.send = function (json) {
|
||||
try {
|
||||
this.ws.send(json);
|
||||
console.log(json);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
return Client;
|
||||
}(stream_1.EventEmitter));
|
||||
exports.Client = Client;
|
26
build/Crypto.js
Normal file
26
build/Crypto.js
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.Crypto = void 0;
|
||||
var crypto = require("crypto");
|
||||
var MPP_SALT = process.env.MPP_SALT;
|
||||
var Crypto = /** @class */ (function () {
|
||||
function Crypto() {
|
||||
}
|
||||
Crypto.getTempID = function () {
|
||||
var hash = crypto.createHash('sha256');
|
||||
hash.update(Date.now().toFixed(2) + Math.random() * 25);
|
||||
return hash.digest('hex').substr(0, 24);
|
||||
};
|
||||
Crypto.getUser_ID = function (ipaddr) {
|
||||
var hash = crypto.createHash('sha256');
|
||||
hash.update(ipaddr + MPP_SALT);
|
||||
return hash.digest('hex').substr(0, 24);
|
||||
};
|
||||
Crypto.getColorFromID = function (_id) {
|
||||
var hash = crypto.createHash('sha256');
|
||||
hash.update("color" + _id);
|
||||
return "#" + hash.digest('hex').substring(0, 6);
|
||||
};
|
||||
return Crypto;
|
||||
}());
|
||||
exports.Crypto = Crypto;
|
174
build/Database.js
Normal file
174
build/Database.js
Normal file
@ -0,0 +1,174 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
exports.__esModule = true;
|
||||
exports.Database = void 0;
|
||||
var mongodb_1 = require("mongodb");
|
||||
var Crypto_1 = require("./Crypto");
|
||||
var MPP_DEFAULT_USERNAME = process.env.MPP_DEFAULT_USERNAME || 'Anonymous';
|
||||
var MPP_MONGO_URI = process.env.MPP_MONGO_URI;
|
||||
var Database = /** @class */ (function () {
|
||||
function Database() {
|
||||
}
|
||||
Database.setup = function (server) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
this.server = server;
|
||||
return [4 /*yield*/, this.client.connect()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
console.log('database connected');
|
||||
this.db = this.client.db('multiplayerpiano');
|
||||
this.userCollection = this.db.collection('users');
|
||||
this.ready = true;
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.getUser = function (_id) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var user;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!this.ready)
|
||||
return [2 /*return*/, {
|
||||
color: '#ffffff',
|
||||
name: MPP_DEFAULT_USERNAME
|
||||
}];
|
||||
return [4 /*yield*/, this.userExists(_id)];
|
||||
case 1:
|
||||
if (!((_a.sent()) == false)) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, this.createUser(_id)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
_a.label = 3;
|
||||
case 3: return [4 /*yield*/, this.userCollection.findOne({ _id: _id })];
|
||||
case 4:
|
||||
user = (_a.sent());
|
||||
return [2 /*return*/, user];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.getPublicUser = function (_id) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var user;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getUser(_id)];
|
||||
case 1:
|
||||
user = (_a.sent());
|
||||
return [2 /*return*/, {
|
||||
name: user.name,
|
||||
_id: user._id,
|
||||
color: user.color
|
||||
}];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.userExists = function (_id) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var exists;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.userCollection.findOne({ _id: _id })];
|
||||
case 1:
|
||||
exists = (_a.sent()) !== null;
|
||||
return [2 /*return*/, exists];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.createUser = function (_id) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var color, user;
|
||||
return __generator(this, function (_a) {
|
||||
color = Crypto_1.Crypto.getColorFromID(_id);
|
||||
user = {
|
||||
_id: _id,
|
||||
name: MPP_DEFAULT_USERNAME,
|
||||
color: color,
|
||||
flags: {
|
||||
"no chat rate limit": false
|
||||
}
|
||||
};
|
||||
this.userCollection.insertOne(user);
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.updateUser = function (_id, data) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.userCollection.updateOne({ _id: _id }, {
|
||||
$set: data
|
||||
});
|
||||
this.server.emit('receive_userset', data);
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.userset = function (_id, set) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.updateUser(_id, {
|
||||
name: set.name
|
||||
});
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
Database.getDefaultUser = function () {
|
||||
return {
|
||||
name: MPP_DEFAULT_USERNAME,
|
||||
color: "#777"
|
||||
};
|
||||
};
|
||||
Database.getMOTD = function () {
|
||||
// let motd = "test";
|
||||
// return motd;
|
||||
};
|
||||
Database.client = new mongodb_1.MongoClient(MPP_MONGO_URI);
|
||||
Database.ready = false;
|
||||
return Database;
|
||||
}());
|
||||
exports.Database = Database;
|
45
build/Server.js
Normal file
45
build/Server.js
Normal file
@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
exports.__esModule = true;
|
||||
exports.Server = void 0;
|
||||
var EventEmitter = require("events");
|
||||
var Database_1 = require("./Database");
|
||||
var WebServer_1 = require("./WebServer");
|
||||
var WebSocketServer_1 = require("./WebSocketServer");
|
||||
var Server = /** @class */ (function (_super) {
|
||||
__extends(Server, _super);
|
||||
function Server() {
|
||||
return _super.call(this) || this;
|
||||
}
|
||||
Server.prototype.bindEventListeners = function () {
|
||||
this.on('receive_userset', function (data) { });
|
||||
};
|
||||
Server.prototype.findClient = function (_id) {
|
||||
};
|
||||
Server.prototype.start = function () {
|
||||
this.webServer = new WebServer_1.WebServer(this);
|
||||
this.wsServer = new WebSocketServer_1.WebSocketServer(this);
|
||||
this.clients = new Map();
|
||||
Database_1.Database.setup(this);
|
||||
this.bindEventListeners();
|
||||
};
|
||||
Server.prototype.destroyClient = function (id) {
|
||||
this.clients["delete"](id);
|
||||
};
|
||||
return Server;
|
||||
}(EventEmitter));
|
||||
exports.Server = Server;
|
45
build/WebServer.js
Normal file
45
build/WebServer.js
Normal file
@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.WebServer = void 0;
|
||||
var express = require("express");
|
||||
var https = require("https");
|
||||
var http = require("http");
|
||||
var MPP_HTTPS_ENABLED = process.env.MPP_HTTPS_ENABLED;
|
||||
var MPP_HTTPS_PORT = process.env.MPP_HTTPS_PORT;
|
||||
var MPP_HTTP_ENABLED = process.env.MPP_HTTP_ENABLED;
|
||||
var MPP_HTTP_PORT = process.env.MPP_HTTP_PORT;
|
||||
var WebServer = /** @class */ (function () {
|
||||
function WebServer(server) {
|
||||
this.server = server;
|
||||
this.startServers();
|
||||
}
|
||||
WebServer.prototype.startServers = function () {
|
||||
var _this = this;
|
||||
this.app = express();
|
||||
this.app.use(express.static('./static'));
|
||||
var router = express.Router();
|
||||
router.use(express.static('./sounds'));
|
||||
this.app.use('/sounds', router);
|
||||
var enableHttps = MPP_HTTPS_ENABLED == "true";
|
||||
var enableHttp = MPP_HTTP_ENABLED == "true";
|
||||
if (enableHttps) {
|
||||
this.httpsServer = https.createServer({
|
||||
key: 'placeholder',
|
||||
cert: 'placeholder' //! TODO fix placeholders
|
||||
}, this.app);
|
||||
this.httpsServer.on('upgrade', function (req, socket, head) {
|
||||
_this.server.wsServer.handleUpgrade(req, socket, head);
|
||||
});
|
||||
this.httpsServer.listen(MPP_HTTP_PORT);
|
||||
}
|
||||
if (enableHttp) {
|
||||
this.httpServer = http.createServer(this.app);
|
||||
this.httpServer.on('upgrade', function (req, socket, head) {
|
||||
_this.server.wsServer.handleUpgrade(req, socket, head);
|
||||
});
|
||||
this.httpServer.listen(MPP_HTTP_PORT);
|
||||
}
|
||||
};
|
||||
return WebServer;
|
||||
}());
|
||||
exports.WebServer = WebServer;
|
31
build/WebSocketServer.js
Normal file
31
build/WebSocketServer.js
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.WebSocketServer = void 0;
|
||||
var WebSocket = require("ws");
|
||||
var Client_1 = require("./Client");
|
||||
var Crypto_1 = require("./Crypto");
|
||||
var WebSocketServer = /** @class */ (function () {
|
||||
function WebSocketServer(server) {
|
||||
this.server = server;
|
||||
this.wss = new WebSocket.Server({
|
||||
noServer: true
|
||||
});
|
||||
this.bindEventListeners();
|
||||
}
|
||||
WebSocketServer.prototype.handleUpgrade = function (req, socket, head) {
|
||||
var _this = this;
|
||||
this.wss.handleUpgrade(req, socket, head, function (ws, req) {
|
||||
_this.wss.emit('connection', ws, req);
|
||||
});
|
||||
};
|
||||
WebSocketServer.prototype.bindEventListeners = function () {
|
||||
var _this = this;
|
||||
this.wss.on('connection', function (ws, req) {
|
||||
var id = Crypto_1.Crypto.getTempID();
|
||||
var cl = new Client_1.Client(_this.server, ws, req, id);
|
||||
_this.server.clients.set(Crypto_1.Crypto.getTempID(), cl);
|
||||
});
|
||||
};
|
||||
return WebSocketServer;
|
||||
}());
|
||||
exports.WebSocketServer = WebSocketServer;
|
6
build/index.js
Normal file
6
build/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
Server: require('./Server').Server,
|
||||
Channel: require('./Channel').Channel,
|
||||
WebServer: require('./WebServer').WebServer,
|
||||
WebSocketServer: require("./WebSocketServer").WebSocketServer
|
||||
};
|
2
build/models/User.js
Normal file
2
build/models/User.js
Normal file
@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
@ -8,11 +8,13 @@ services:
|
||||
dockerfile: ./Dockerfile
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
MPP_PORT: ${PORT}
|
||||
MPP_HTTP_PORT: ${MPP_HTTP_PORT}
|
||||
MPP_HTTPS_PORT: ${MPP_HTTPS_PORT}
|
||||
MPP_DEBUG: 'true'
|
||||
MPP_MONGO_URI: mongodb://multiplayerpiano:27017
|
||||
ports:
|
||||
- ${PORT}:${PORT}
|
||||
- ${MPP_HTTP_PORT}:${MPP_HTTP_PORT}
|
||||
- ${MPP_HTTPS_PORT}:${MPP_HTTPS_PORT}
|
||||
mongo:
|
||||
image: 'mongo'
|
||||
container_name: multiplayerpiano
|
||||
|
10
index.js
10
index.js
@ -1,13 +1,9 @@
|
||||
require('dotenv').config({
|
||||
debug: false,
|
||||
encoding: 'utf-8',
|
||||
path: '.env'
|
||||
});
|
||||
|
||||
const MPP_PORT = process.env.MPP_PORT;
|
||||
const { Server } = require('./build');
|
||||
|
||||
console.log(MPP_PORT);
|
||||
|
||||
const MPP = require('./build');
|
||||
|
||||
MPP.Server.start();
|
||||
const server = new Server();
|
||||
server.start();
|
||||
|
2
mongo-volume/WiredTiger
Normal file
2
mongo-volume/WiredTiger
Normal file
@ -0,0 +1,2 @@
|
||||
WiredTiger
|
||||
WiredTiger 10.0.1: (April 12, 2021)
|
1
mongo-volume/WiredTiger.lock
Normal file
1
mongo-volume/WiredTiger.lock
Normal file
@ -0,0 +1 @@
|
||||
WiredTiger lock file
|
6
mongo-volume/WiredTiger.turtle
Normal file
6
mongo-volume/WiredTiger.turtle
Normal file
@ -0,0 +1,6 @@
|
||||
WiredTiger version string
|
||||
WiredTiger 10.0.1: (April 12, 2021)
|
||||
WiredTiger version
|
||||
major=10,minor=0,patch=1
|
||||
file:WiredTiger.wt
|
||||
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,local_retention=300,name=,object_target_size=10M),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.4=(addr="018a81e487e8d0b98b81e4f9befd518c81e433667fe3808080e2bfc0e24fc0",order=4,time=1635005559,size=32768,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=139,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=11,run_write_gen=4)),checkpoint_backup_info=,checkpoint_lsn=(2,36736)
|
BIN
mongo-volume/WiredTiger.wt
Normal file
BIN
mongo-volume/WiredTiger.wt
Normal file
Binary file not shown.
BIN
mongo-volume/WiredTigerHS.wt
Normal file
BIN
mongo-volume/WiredTigerHS.wt
Normal file
Binary file not shown.
BIN
mongo-volume/_mdb_catalog.wt
Normal file
BIN
mongo-volume/_mdb_catalog.wt
Normal file
Binary file not shown.
BIN
mongo-volume/collection-0--7692121742958003173.wt
Normal file
BIN
mongo-volume/collection-0--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/collection-10--7692121742958003173.wt
Normal file
BIN
mongo-volume/collection-10--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/collection-2--7692121742958003173.wt
Normal file
BIN
mongo-volume/collection-2--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/collection-4--7692121742958003173.wt
Normal file
BIN
mongo-volume/collection-4--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/collection-6--7692121742958003173.wt
Normal file
BIN
mongo-volume/collection-6--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/collection-8--7692121742958003173.wt
Normal file
BIN
mongo-volume/collection-8--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/diagnostic.data/metrics.2021-10-23T16-07-01Z-00000
Normal file
BIN
mongo-volume/diagnostic.data/metrics.2021-10-23T16-07-01Z-00000
Normal file
Binary file not shown.
BIN
mongo-volume/diagnostic.data/metrics.2021-10-23T16-10-41Z-00000
Normal file
BIN
mongo-volume/diagnostic.data/metrics.2021-10-23T16-10-41Z-00000
Normal file
Binary file not shown.
BIN
mongo-volume/index-1--7692121742958003173.wt
Normal file
BIN
mongo-volume/index-1--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/index-11--7692121742958003173.wt
Normal file
BIN
mongo-volume/index-11--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/index-3--7692121742958003173.wt
Normal file
BIN
mongo-volume/index-3--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/index-5--7692121742958003173.wt
Normal file
BIN
mongo-volume/index-5--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/index-7--7692121742958003173.wt
Normal file
BIN
mongo-volume/index-7--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/index-9--7692121742958003173.wt
Normal file
BIN
mongo-volume/index-9--7692121742958003173.wt
Normal file
Binary file not shown.
BIN
mongo-volume/journal/WiredTigerLog.0000000002
Normal file
BIN
mongo-volume/journal/WiredTigerLog.0000000002
Normal file
Binary file not shown.
BIN
mongo-volume/journal/WiredTigerPreplog.0000000001
Normal file
BIN
mongo-volume/journal/WiredTigerPreplog.0000000001
Normal file
Binary file not shown.
BIN
mongo-volume/journal/WiredTigerPreplog.0000000002
Normal file
BIN
mongo-volume/journal/WiredTigerPreplog.0000000002
Normal file
Binary file not shown.
BIN
mongo-volume/sizeStorer.wt
Normal file
BIN
mongo-volume/sizeStorer.wt
Normal file
Binary file not shown.
BIN
mongo-volume/storage.bson
Normal file
BIN
mongo-volume/storage.bson
Normal file
Binary file not shown.
@ -13,10 +13,17 @@
|
||||
"test": "npm run build && npm start"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/mongodb": "^4.0.7",
|
||||
"@types/node": "^16.11.2",
|
||||
"@types/ws": "^8.2.0",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^10.0.0"
|
||||
"chalk": "^4.1.2",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"mongodb": "^4.1.3",
|
||||
"ws": "^8.2.3"
|
||||
}
|
||||
}
|
||||
|
2
sounds/.gitignore
vendored
Normal file
2
sounds/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
.DS_Store
|
BIN
sounds/Emotional/a-1.mp3
Normal file
BIN
sounds/Emotional/a-1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a0.mp3
Normal file
BIN
sounds/Emotional/a0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a1.mp3
Normal file
BIN
sounds/Emotional/a1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a2.mp3
Normal file
BIN
sounds/Emotional/a2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a3.mp3
Normal file
BIN
sounds/Emotional/a3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a4.mp3
Normal file
BIN
sounds/Emotional/a4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a5.mp3
Normal file
BIN
sounds/Emotional/a5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/a6.mp3
Normal file
BIN
sounds/Emotional/a6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as-1.mp3
Normal file
BIN
sounds/Emotional/as-1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as0.mp3
Normal file
BIN
sounds/Emotional/as0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as1.mp3
Normal file
BIN
sounds/Emotional/as1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as2.mp3
Normal file
BIN
sounds/Emotional/as2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as3.mp3
Normal file
BIN
sounds/Emotional/as3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as4.mp3
Normal file
BIN
sounds/Emotional/as4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as5.mp3
Normal file
BIN
sounds/Emotional/as5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/as6.mp3
Normal file
BIN
sounds/Emotional/as6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b-1.mp3
Normal file
BIN
sounds/Emotional/b-1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b0.mp3
Normal file
BIN
sounds/Emotional/b0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b1.mp3
Normal file
BIN
sounds/Emotional/b1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b2.mp3
Normal file
BIN
sounds/Emotional/b2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b3.mp3
Normal file
BIN
sounds/Emotional/b3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b4.mp3
Normal file
BIN
sounds/Emotional/b4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b5.mp3
Normal file
BIN
sounds/Emotional/b5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/b6.mp3
Normal file
BIN
sounds/Emotional/b6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c0.mp3
Normal file
BIN
sounds/Emotional/c0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c1.mp3
Normal file
BIN
sounds/Emotional/c1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c2.mp3
Normal file
BIN
sounds/Emotional/c2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c3.mp3
Normal file
BIN
sounds/Emotional/c3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c4.mp3
Normal file
BIN
sounds/Emotional/c4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c5.mp3
Normal file
BIN
sounds/Emotional/c5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c6.mp3
Normal file
BIN
sounds/Emotional/c6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/c7.mp3
Normal file
BIN
sounds/Emotional/c7.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs0.mp3
Normal file
BIN
sounds/Emotional/cs0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs1.mp3
Normal file
BIN
sounds/Emotional/cs1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs2.mp3
Normal file
BIN
sounds/Emotional/cs2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs3.mp3
Normal file
BIN
sounds/Emotional/cs3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs4.mp3
Normal file
BIN
sounds/Emotional/cs4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs5.mp3
Normal file
BIN
sounds/Emotional/cs5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/cs6.mp3
Normal file
BIN
sounds/Emotional/cs6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d0.mp3
Normal file
BIN
sounds/Emotional/d0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d1.mp3
Normal file
BIN
sounds/Emotional/d1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d2.mp3
Normal file
BIN
sounds/Emotional/d2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d3.mp3
Normal file
BIN
sounds/Emotional/d3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d4.mp3
Normal file
BIN
sounds/Emotional/d4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d5.mp3
Normal file
BIN
sounds/Emotional/d5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/d6.mp3
Normal file
BIN
sounds/Emotional/d6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds0.mp3
Normal file
BIN
sounds/Emotional/ds0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds1.mp3
Normal file
BIN
sounds/Emotional/ds1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds2.mp3
Normal file
BIN
sounds/Emotional/ds2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds3.mp3
Normal file
BIN
sounds/Emotional/ds3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds4.mp3
Normal file
BIN
sounds/Emotional/ds4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds5.mp3
Normal file
BIN
sounds/Emotional/ds5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/ds6.mp3
Normal file
BIN
sounds/Emotional/ds6.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e0.mp3
Normal file
BIN
sounds/Emotional/e0.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e1.mp3
Normal file
BIN
sounds/Emotional/e1.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e2.mp3
Normal file
BIN
sounds/Emotional/e2.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e3.mp3
Normal file
BIN
sounds/Emotional/e3.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e4.mp3
Normal file
BIN
sounds/Emotional/e4.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e5.mp3
Normal file
BIN
sounds/Emotional/e5.mp3
Normal file
Binary file not shown.
BIN
sounds/Emotional/e6.mp3
Normal file
BIN
sounds/Emotional/e6.mp3
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user