Initial Comit
The Server has overcome it's early Development Steps. although it still is a bit unstable it works in it's actual state
This commit is contained in:
9
bin/classes/IsJsonString.js
Normal file
9
bin/classes/IsJsonString.js
Normal file
@ -0,0 +1,9 @@
|
||||
function IsJsonString(str) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
module.exports = IsJsonString;
|
18
bin/classes/decrypt.js
Normal file
18
bin/classes/decrypt.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {String} content Zu entschlüsselnde Nachricht
|
||||
*/
|
||||
'decrypt': function (content,passcode) {
|
||||
var result = []; var str = '';
|
||||
var codesArr = JSON.parse(content);var passLen = passcode.length ;
|
||||
for(var i = 0 ; i < codesArr.length ; i++) {
|
||||
var passOffset = i%passLen ;
|
||||
var calAscii = (codesArr[i]-passcode.charCodeAt(passOffset));
|
||||
result.push(calAscii) ;
|
||||
}
|
||||
for(var i = 0 ; i < result.length ; i++) {
|
||||
var ch = String.fromCharCode(result[i]); str += ch ;
|
||||
}
|
||||
return str ;
|
||||
}
|
||||
}
|
11
bin/classes/events/listener.js
Normal file
11
bin/classes/events/listener.js
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @param {array} events Die Events die Ausgeführt werden
|
||||
*/
|
||||
function listener(events, event){
|
||||
events.forEach(e => {
|
||||
if(event === e.name) {
|
||||
e.function();
|
||||
}
|
||||
})
|
||||
}
|
||||
module.exports = listener;
|
27
bin/classes/websocket.js
Normal file
27
bin/classes/websocket.js
Normal file
@ -0,0 +1,27 @@
|
||||
function socket(WebSocket, config) {
|
||||
// Websocket
|
||||
const wss = new WebSocket.Server({
|
||||
port: config.websocket,
|
||||
perMessageDeflate: {
|
||||
zlibDeflateOptions: {
|
||||
// See zlib defaults.
|
||||
chunkSize: 1024,
|
||||
memLevel: 7,
|
||||
level: 3
|
||||
},
|
||||
zlibInflateOptions: {
|
||||
chunkSize: 10 * 1024
|
||||
},
|
||||
// Other options settable:
|
||||
clientNoContextTakeover: true, // Defaults to negotiated value.
|
||||
serverNoContextTakeover: true, // Defaults to negotiated value.
|
||||
serverMaxWindowBits: 10, // Defaults to negotiated value.
|
||||
// Below options specified as default values.
|
||||
concurrencyLimit: 10, // Limits zlib concurrency for perf.
|
||||
threshold: 1024 // Size (in bytes) below which messages
|
||||
// should not be compressed.
|
||||
}
|
||||
});
|
||||
return wss;
|
||||
}
|
||||
module.exports = socket;
|
Reference in New Issue
Block a user