Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update socket.io and uuid packages #7793

Merged
merged 8 commits into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/api3/shared/operationTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const apiConst = require('../const.json')
, stringTools = require('./stringTools')
, uuidv5 = require('uuid/v5')
, uuid = require('uuid')
, uuidNamespace = [...Buffer.from("NightscoutRocks!", "ascii")] // official namespace for NS :-)
;

Expand Down Expand Up @@ -103,7 +103,7 @@ function calculateIdentifier (doc) {
key += '_' + doc.eventType;
}

return uuidv5(key, uuidNamespace);
return uuid.v5(key, uuidNamespace);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ client.load = function load (serverSettings, callback) {
// Client-side code to connect to server and handle incoming data
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* global io */
client.socket = socket = io.connect();
client.socket = socket = io.connect({ transports: ["polling"] });

socket.on('dataUpdate', dataUpdate);

Expand Down
14 changes: 10 additions & 4 deletions lib/server/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@ function init (env, ctx, server) {

function start () {
io = require('socket.io')({
'transports': ['xhr-polling']
, 'log level': 0
'log level': 0
}).listen(server, {
//these only effect the socket.io.js file that is sent to the client, but better than nothing
'browser client minification': true
, 'browser client etag': true
, 'browser client gzip': false
, 'perMessageDeflate': {
threshold: 512
}
, transports: ["polling", "websocket"]
, httpCompression: {
threshold: 512
}
});

ctx.bus.on('teardown', function serverTeardown () {
Expand Down Expand Up @@ -117,7 +123,7 @@ function init (env, ctx, server) {
delta.status = status(ctx.ddata.profiles);
lastProfileSwitch = ctx.ddata.lastProfileFromSwitch;
}
io.to('DataReceivers').emit('dataUpdate', delta);
io.to('DataReceivers').compress(true).emit('dataUpdate', delta);
}
}

Expand Down Expand Up @@ -179,7 +185,7 @@ function init (env, ctx, server) {
callback({ result: 'success' });
}
//TODO: use opts to only send delta for retro data
socket.emit('retroUpdate', { devicestatus: lastData.devicestatus });
socket.compress(true).emit('retroUpdate', { devicestatus: lastData.devicestatus });
console.info('sent retroUpdate', opts);
});

Expand Down
Loading