Socket
Socket
Sign inDemoInstall

engine.io-client

Package Overview
Dependencies
Maintainers
2
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engine.io-client

Client for the realtime Engine


Version published
Weekly downloads
4.5M
increased by0.24%
Maintainers
2
Weekly downloads
 
Created

What is engine.io-client?

The engine.io-client npm package is a client-side library that provides bidirectional event-based communication between web clients and servers. It is the client component of the Engine.IO protocol, which is a transport layer built on top of WebSocket and other transport mechanisms to provide a reliable, low-latency connection for real-time applications.

What are engine.io-client's main functionalities?

Establishing a connection

This feature allows you to establish a connection to an Engine.IO server. The 'open' event is emitted when the connection is successfully established.

const eio = require('engine.io-client');
const socket = eio('ws://localhost');
socket.on('open', function(){
  console.log('Connection established');
});

Sending messages

Once a connection is established, you can send messages to the server using the 'send' method.

socket.send('Hello World!');

Receiving messages

You can listen for messages from the server with the 'message' event. The callback function receives the message data as its argument.

socket.on('message', function(data){
  console.log('Received message:', data);
});

Handling connection errors

The 'error' event is emitted when there is a connection error. The callback function receives the error object as its argument.

socket.on('error', function(error){
  console.error('Connection error:', error);
});

Closing the connection

The 'close' event is emitted when the connection is closed. The callback function receives the reason and a description as arguments.

socket.on('close', function(reason, description){
  console.log('Connection closed', reason, description);
});

Other packages similar to engine.io-client

FAQs

Package last updated on 04 Jun 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc