Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
diffusion
Advanced tools
The Diffusion JavaScript API allows interaction with a Diffusion server from both the browser and Node.js.
Clients use a WebSocket or HTTP connection to send and receive, as well as perform other functions such as adding, removing or updating topics.
A client Session maintains a connection to the server. To create a session, simply do
diffusion.connect('diffusion.example.com');
It is also possible to connect with a map of options
diffusion.connect({
host : 'diffusion.example.com',
port : 8080,
secure : false,
principal : 'admin',
credentials : 'password'
});
Connecting returns a Promise - this will succeed if the session could be connected, or fail if not.
diffusion.connect('diffusion.example.com').then(function(session) {
// Connected!
}, function(error) {
// Failed to connect :(
});
Sessions emit events to indicate their status such as when they are disconnected or closed. These events are easy to listen to:
session.on('disconnect', function() {
// Lost connection to the server!
});
session.on('close', function() {
// Session is closed!
});
Once a session is closed, it can never be re-opened.
Data in Diffusion is distributed via topics. A topic has state, which can be updated. The state can be simple - such as a string or an integer - or more complex - such as a JSON document. Each topic has a unique path and is addressed through a topic selector.
The way that a session receives data is by subscribing. Subscriptions allow the session to select one or more topics to receive values from. A session may subscribe to many topics, as well as subscribe to the same topic multiple times.
session.subscribe('topic/foo')
To attach listeners for received values, a ValueStream is used. The stream that is returned will emit events when the value of the selected topic changes.
session.stream('topic/foo').asType(diffusion.datatypes.json()).on('value', function(topic, specification, update) {
// Do something with the value
var value = update.get();
});
It is possible to register any number of streams to a subscription's events. They will each be called when a new value is received.
FAQs
Diffusion JavaScript client
The npm package diffusion receives a total of 5,097 weekly downloads. As such, diffusion popularity was classified as popular.
We found that diffusion demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.