
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
evsocket-client
Advanced tools
EvSocket is abstracted WebSocket module with event driven interface and rich functinalities.
There is well-known alternative for this module, Socket.io, but unfortunately Socket.io doesn't support React Native, because it uses Node.js features inside. This module built for provide highly abstracted WebSocket interface without any Node.js related features, only used pure JavaScript features. When I was used WebSocket with vanila JS, it was really hard to make something rich. EvSocket provides similar interface like Socket.io with only uses WebSocket + JavaScript features so it is safe to use any WebSocket supporting JavaScript platform.
Client module for evsocket. Abstracted WebSocket module with event driven interface and rich functionalities. See full example here.
Create new EvSocket. Available options are:
var socket = new EvSocket('ws://localhost:3000');
socket.on('open', function() {
console.log('Connected as ' + socket.id);
});
Close WebSocket.
var socket = new EvSocket('ws://localhost:3000');
socket.on('open', function() {
console.log('Connected as ' + socket.id);
socket.close();
});
Send the data with event name to client.
var socket = new EvSocket('ws://localhost:3000');
...
socket.send('some-server-event', { a: 1, b: 2});
Send the binary data with event name to client.
var socket = new EvSocket('ws://localhost:3000');
...
socket.sendBinary('some-server-event', new Uint8Array([1,2,3,4,5,6,7,8]));
Add event listener.
Add event listener that execute only once and delete itself automatically.
Remove event listener. If fn argument is undefined, remove all listeners in specified event name.
Fires event of server socket.
Join the specified channel.
var socket = new EvSocket('ws://localhost:3000');
socket.on('channeljoin', (channelName) {
console.log(channelName);
socket.leave();
});
socket.on('channelleave', () => {
console.log('Channel left.');
});
socket.join('channel1');
Leave the current channel.
var socket = new EvSocket('ws://localhost:3000');
socket.on('channeljoin', (channelName) {
console.log(channelName);
socket.leave();
});
socket.on('channelleave', () => {
console.log('Channel left.');
});
socket.join('channel1');
Broadcast message to users who currently in same channel.
var socket = new EvSocket('ws://localhost:3000');
socket.on('open', () => {
socket.join('channel1');
});
socket.on('channeljoin', (channelName) => {
socket.broadcast('chat', `User ${socket.id} joined to ${channelName}.`);
});
You can use any name of the event, except these default events. These default events are triggering by EvSocket directly.
Fired on EvSocket is ready.
Fired on EvSocket passed authentication.
Fired on EvSocket failed authentication. After this event occurs, socket will close.
Fired on socket closed. Arguments are code and reason, please check this: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
Fired on error occured. Has one argument, error object.
Fired on user joined channel.
Fired on user left channel.
FAQs
EvSocket is abstracted WebSocket module with event driven interface and rich functinalities.
We found that evsocket-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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.