Socket
Socket
Sign inDemoInstall

@types/socket.io

Package Overview
Dependencies
25
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/socket.io

Stub TypeScript definitions entry for socket.io, which provides its own types definitions


Version published
Maintainers
1
Install size
2.39 MB
Created

Package description

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

Readme

Source

This is a stub types definition for @types/socket.io (https://github.com/socketio/socket.io#readme).

socket.io provides its own type definitions, so you don't need @types/socket.io installed!

FAQs

Last updated on 14 May 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc