Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
queued-socket.io
Advanced tools
Socket.io client with offline queue
Install using npm:
npm install queued-socket.io
const socket = require('queued-socket.io');
// Before there is a socket connection, add events. These will be queued and run after the connection is established.
socket.on('ping', () => console.log('ping'));
socket.on('disconnect', () => console.log('disconnected'));
socket.once('ping', () => console.log('One time ping'));
socket.emit('authentication', { token: 'loginToken' }, 1);
const options = {
path: '/socket',
transports: ['websocket']
};
const client = socket.connect('http://localhost:5000', options);
console.log(`Socket is ${socket.isConnected() ? 'connected' : 'disconnected'}`);
Socket module
Retrieve the client
Kind: inner method of socket
Returns: socket.io client
Access: public
Boolean
Check if the socket is connected
Kind: inner method of socket
Returns: Boolean
- socket connection status
Access: public
Send an event to the socket, when the socket is not connected, add an emit event to the queue.
Kind: inner method of socket
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
data | Object | The data to send to the socket when the event is triggered. | |
priority | Number | 2 | The priority of the event. |
Wrapper around socket.on that adds priority and caching
Kind: inner method of socket
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
callback | function | The callback function that the sockets call when the event is triggered. | |
priority | Number | 2 | The priority of the event. |
Wrapper around socket.off that adds priority and caching
Kind: inner method of socket
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
priority | Number | 2 | The priority of the event. |
Wrapper around socket.once that adds priority and caching
Kind: inner method of socket
Returns: socket.io client
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
callback | function | The callback function that the sockets call when the event is triggered. | |
priority | Number | 2 | The priority of the event. |
Connect to socket.io, if socket is already connected, returns that socket.
Kind: inner method of socket
Returns: socket.io client
Access: public
Param | Type | Description |
---|---|---|
uri | String | The connection uri of the host. |
options | Object | Options object used by socket.io. |
Events module
Adds a socket event to the socket, when the socket is not connected, add the add event to the queue.
Kind: inner method of events
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
callback | function | The callback function that the sockets call when the event is triggered. | |
priority | Number | 2 | The priority of the event. |
Adds a single run socket event to the socket, when the socket is not connected, add the once event to the queue.
Kind: inner method of events
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
callback | function | The callback function that the sockets call when the event is triggered. | |
priority | Number | 2 | The priority of the event. |
Remove all socket events from the socket, when the socket is not connected, add the clear event to the queue.
Kind: inner method of events
Access: public
Param | Type | Default | Description |
---|---|---|---|
priority | Number | 2 | The priority of the event. |
Array.<Object>
Retrieve all registered events
Kind: inner method of events
Returns: Array.<Object>
- Registered events
Access: public
Remove a socket event from the socket, when the socket is not connected, add a remove event to the queue.
Kind: inner method of events
Access: public
Param | Type | Default | Description |
---|---|---|---|
event | String | The event name that needs to be added to the socket. | |
priority | Number | 2 | The priority of the event. |
queued-socket.io makes use of debug. To see the output in the console run this in the console:
localStorage.debug = 'queued-socket.io*';
Please submit all issues and pull requests to the anchorchat/queued-socket.io repository!
Run tests using npm test
.
Make sure your working directory is clean!
git checkout master && git fetch && git merge origin/master
npm run prepare
npm version <patch|minor|major> -m '<commit message containing changes for this release>'
git push origin master
git push --tags
npm publish
If you have any problem or suggestion please open an issue here.
FAQs
Socket.io client with offline queue
The npm package queued-socket.io receives a total of 11 weekly downloads. As such, queued-socket.io popularity was classified as not popular.
We found that queued-socket.io 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.