Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
spacebro-client
Advanced tools
Allow to automagically 🌟 connect to a Spacebro server
npm i -S spacebro-client
First, you need to start a spaceBro server. To run one locally, run the following line in your terminal (mind that you need to have spaceBro installed):
spacebro
Then, it's time to write some code:
const spacebroClient = require('spacebro-client')
spacebroClient.connect('localhost', 8888, {
clientName: 'foo',
channelName: 'bar'
})
spacebroClient.on('pong', function () { console.log('pong') })
spacebroClient.emit('ping')
Allows you to connect to a spaceBro server. Options is hash table of settings that will be used to define your client. If you choose not to pass an address (string) and a port (integer), spaceBro will try to connect to a server using MDNS.
Available options are :
Broadcast a specific event to all the apps in the channel. data must be an object.
Send an event to a specific target in the channel. data must be an object.
Listen to a specific event.
Listen to a specific event, the listener only once.
Before you send an event to the server, all packers associated with that event and all global packers (with no associated event) are called and applied to that event. They receive a single argument which is an object with two properties, the eventName and the data, and can return a new version of those data. If nothing is returned, the message will remain unchanged.
Unpackers are call when you receive a message from the server, before any handler is called. You can use to alter data (same as packers) but also to check the message as if an unpacker returns false, the message will not be sent to the handlers, it will also break the unpacking chain.
Please follow standard style conventions.
We will name our version by the name of the stars that you can find here: https://en.wikipedia.org/wiki/List_of_stars_in_Andromeda
Currently latest correspond to Sirrah which belongs to the Andromeda galaxy.
You can modify the source in src/index.js
. Run npm run build
to transpile and test.
You can also run npm run build-example
Enjoy !
FAQs
🌟 Connect easily to a Spacebro server
We found that spacebro-client 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.