![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
socket.io-backlog
Advanced tools
socket.io adapter to store and send previous messages upon connection
A socket.io adapter that backlogs messages given a custom monotonous stamp.
mstamp is either a number or a string. If it's a string, it is parsed using Date.parse() and converted to a number.
If no mstamp is given when joining, no backlog is sent. If no mstamp property exists on emitted messages, they are not stored for backlogging.
Rule of thumb: keep mstamp generation on server side to keep the same stamp for all.
In this example, all messages are given a default mstamp.
io.adapter(require('socket.io-backlog')({
length: 1000, // how many messages are backlogged for each room
cacheSize: 100, // cache size for packets of messages for each room
key: 'mtime' // which key in messages is compared to mstamp
}));
io.on('connection', function(socket) {
socket.on('join', function(data) {
socket.backlog(data.mtime).join(data.room);
});
socket.on('leave', function(data) {
socket.leave(data.room);
});
socket.on('message', function(msg) {
// this mtime will be converted to ISO 8601 by JSON.stringify
if (!msg.mtime) msg.mtime = Date.now();
io.to(msg.room).emit('message', msg);
});
});
In this example, messages missed during a disconnection are sent back to the client upon reconnection.
var mstamp;
io.on('connect', function() {
io.emit('join', {
room: this.room,
mtime: mstamp
});
});
io.on('message', function(msg) {
if (msg.mtime) mstamp = msg.mtime;
// ...
});
FAQs
socket.io adapter to store and send previous messages upon connection
We found that socket.io-backlog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.