
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
sse.io-server-nodejs
Advanced tools
NodeJS server for SSE-IO.
const sseio = require('sse.io-server-nodejs')
Import using ES6
import * as sseio from 'sse.io-server-nodejs';
The following example attaches sse.io to a plain Node.JS HTTP server listening on port 3000.
const server = http.createServer();
const sseServer = sseio.newServer(server, { path: '/user/:userId/foo' });
const eventHandler = sseServer.registerEventHandler('event', {
getRoomId: (context): string => {
return context.params.guid;
},
});
server.listen(3000);
eventHandler.send('roomId', 'message');
const sseServer = sseio.newServer({ path: '/user/:userId/foo' });
// ... regist event handler
sseServer.listen(3000);
const app = new require('koa')();
const server = require('http').createServer(app.callback());
const sseServer = sseio.newServer(server, {
path: '/files/:fileGuid/pull'
})
// ... regist event handler
server.listen(3000);
const app = require('express')();
const server = require('http').createServer(app);
const sseServer = sseio.newServer(server, {
path: '/files/:fileGuid/pull'
})
// ... regist event handler
server.listen(3000);
httpServer
http.Server The server to bind to.options
(Object)
path
(String) The url path. You can add path params as well like /users/:userId
.Server
options
(Object) See above for available options.Server
Usually using for standalone mode.
event
(String) The event you want to handle.options
(Object)
getRoomId
(Function) (context: sseContext) => string
Return the room ID.fetch
(Function, Optional) (context: sseContext) => Promise<any>
It will be executed once after a client is connected, and send the result to the clientEventHandler
port
(Number) the port to listen onStarts the HTTP server listening for connections, usually using for standalone mode.
Register a handler for the event. The 'error' event must be handled.
Event: 'conn:create'
callback
(Function) The clientId
will be passed to the callback functionFired when a new connection is established.
sseServer.on('conn:create', clientId => {
console.log(clientId);
})
Event: 'conn:close'
callback
(Function) The clientId
will be passed to the callback functionFired when a connection is closed.
Event: 'error'
callback
(Function) an Error will be passed to the callback functionFired when an error occurs.
sseServer.on('error', err => {
console.error(err);
})
It's an object containing params
and query
keys.
params
The path params parse from urlquery
The query params parse from urlroomId
(String) Room idmessage
(any) Message be to send. It can be any type. If it's not a string, then it will be stringify by JSON.stringify()
.Send a message to the clients in room.
Register a handler for the event.
Event: 'room:create'
callback
(Function) The roomId
will be passed to the callback functionFired when a room is created.
eventHandler.on('room:create', roomId => {
console.log('a room:', roomId, 'has been created');
})
Event: 'room:empty'
callback
(Function) The roomId
will be passed to the callback functionFired when a room is empty.
FAQs
NodeJS server for SSE-IO
The npm package sse.io-server-nodejs receives a total of 14 weekly downloads. As such, sse.io-server-nodejs popularity was classified as not popular.
We found that sse.io-server-nodejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.