Socket
Socket
Sign inDemoInstall

@types/socket.io

Package Overview
Dependencies
3
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/socket.io

TypeScript definitions for socket.io


Version published
Weekly downloads
138K
decreased by-4.3%
Maintainers
1
Install size
733 kB
Created
Weekly downloads
 

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

Installation

npm install --save @types/socket.io

Summary

This package contains type definitions for socket.io (http://socket.io/).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/socket.io.

Additional Details

  • Last updated: Thu, 21 May 2020 20:08:59 GMT
  • Dependencies: @types/engine.io, @types/node
  • Global values: SocketIO

Credits

These definitions were written by PROGRE, Damian Connolly, Florent Poujol, KentarouTakeda, Alexey Snigirev, Ezinwa Okpoechi, Marek Urbanowicz, and Kevin Kam.

FAQs

Last updated on 21 May 2020

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc