![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@feathersjs/socket-commons
Advanced tools
Readme
Shared functionality for websocket providers like @feathers/socketio and @feathersjs/primus. Only intended to be used internally by other Feathers real-time providers.
@feathersjs/socket-commons
contains internal shared functionality for Feathers real-time providers (currently Socket.io and Primus).
lib/client.js
is a base socket service client
lib/index.js
returns a configurable function and requires the following options:
done
- A Promise that resolves once the real-time protocol server has been set upemit
- The name of the method to emit data to a socket ('emit'
for Socket.io and 'send'
for Primus)socketKey
- A string or ES6 Symbol which stores the actual socket connectiongetParams
- A function that returns the Feathers connection options for a socketChannels provide channel functionality for bi-directional Feathers service providers. It is e.g. used by the Socket.io and Primus provider to quickly determine what messages to send to connected clients.
const channels = require('@feathersjs/socket-commons/lib/channels');
app.channel(... names)
Returns a named or combined channel object.
const channel = app.channel('test'); // return a `test` channel
channel.join(connection); // join a channel
channel.leave(connection); // leave a channel
channel.filter(connection => {}) // return a new channel with filtered connections
channel.length // return the number of connections
channel.connections // all connections in this channel
const combined = app.channel('test', 'other'); // return a combined channel
combined.join(connection); // join the `test` and `other` channel
combined.leave(connection); // leave the `test` and `other` channel
channel.filter(connection => {}) // return a new channel with filtered connections (connections will only be iterated once)
combined.length // return the number of connections
combined.connections // all connections in the combined channel (if a connection is in multiple channels it will only show once)
app.service('servicename').publish(event, callback)
, app.service('servicename').publish(callback)
Register a publishing callback for a service and event (or all events) that returns a (named or combined) channel.
app.use('/test', {
create(data) {
return Promise.resolve(data);
}
});
// `created` event for the `test` service
app.service('test').publish('created', (data, hook) =>
app.channel('*')
);
// `created` event for the `test` service, sending different data to two different channels
app.service('test').publish('created', (data, hook) => {
return [
app.channel('admins'),
app.channel('users').send(_.omit(data, 'groups', 'email'))
];
});
// All events for all services
app.publish((data, hook) =>
app.channel('*')
);
// All `created` events for all services
app.publish('created', (data, hook) =>
app.channel('*')
);
// All events for `test` service
app.service('test').publish((data, hook) =>
app.channel('*')
);
app.on('publish', function(event, channel, hook) {})
An event that will be sent every time a service event that has connections to publish to happens. channel
is a combined channel with all connections to publish the event to.
Note: If there are no channels or connections the
publish
event will not be sent.
app.on('publish', (event, channel, hook) => {
channel.connections.forEach(connection => {
// Do something with `connection`
});
});
Copyright (c) 2015
Licensed under the MIT license.
FAQs
Shared functionality for websocket providers
The npm package @feathersjs/socket-commons receives a total of 2,905 weekly downloads. As such, @feathersjs/socket-commons popularity was classified as popular.
We found that @feathersjs/socket-commons demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.