Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/socket.io

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/socket.io

TypeScript definitions for socket.io

  • 1.4.37
  • npm
  • Socket score

Version published
Weekly downloads
139K
decreased by-12.44%
Maintainers
1
Weekly downloads
 
Created

What is @types/socket.io?

@types/socket.io provides TypeScript type definitions for the Socket.IO library, which is used for real-time, bidirectional communication between web clients and servers.

What are @types/socket.io's main functionalities?

Server-Side Socket Handling

This feature allows you to set up a Socket.IO server that listens for client connections and disconnections.

const io = require('socket.io')(3000);
io.on('connection', (socket) => {
  console.log('a user connected');
  socket.on('disconnect', () => {
    console.log('user disconnected');
  });
});

Client-Side Socket Handling

This feature allows you to set up a Socket.IO client that connects to a server and listens for connection and disconnection events.

const socket = io('http://localhost:3000');
socket.on('connect', () => {
  console.log('connected to server');
});
socket.on('disconnect', () => {
  console.log('disconnected from server');
});

Emitting and Listening to Events

This feature allows you to emit and listen to custom events between the server and client.

const io = require('socket.io')(3000);
io.on('connection', (socket) => {
  socket.on('chat message', (msg) => {
    io.emit('chat message', msg);
  });
});

const socket = io('http://localhost:3000');
socket.emit('chat message', 'Hello World');
socket.on('chat message', (msg) => {
  console.log('message: ' + msg);
});

Other packages similar to @types/socket.io

FAQs

Package last updated on 18 Aug 2018

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