Socket
Socket
Sign inDemoInstall

@types/socket.io

Package Overview
Dependencies
1
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/socket.io


Version published
Maintainers
1
Install size
713 kB
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

Installation

npm install --save @types/socket.io

Summary

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

Details

Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/socket.io

Additional Details

  • Last updated: Fri, 20 May 2016 17:00:49 GMT
  • File structure: Mixed
  • Library Dependencies: node
  • Module Dependencies: none
  • Global values: none

Credits

These definitions were written by PROGRE https://github.com/progre/, Damian Connolly https://github.com/divillysausages/, Florent Poujol https://github.com/florentpoujol/.

FAQs

Last updated on 20 May 2016

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc