socket.io-redis

  • Version 6.1.1
  • Published
  • 41.5 kB
  • 5 dependencies
  • MIT license

Install

npm i socket.io-redis
yarn add socket.io-redis
pnpm add socket.io-redis

Overview

[![Build Status](https://github.com/socketio/socket.io-redis/workflows/CI/badge.svg?branch=master)](https://github.com/socketio/socket.io-redis/actions) [![NPM version](https://badge.fury.io/js/socket.io-redis.svg)](http://badge.fury.io/js/socket.io-redis

Index

Functions

function createAdapter

createAdapter: {
(uri: string, opts?: Partial<RedisAdapterOptions>): any;
(opts: Partial<RedisAdapterOptions>): any;
};
  • Returns a redis Adapter class.

    Parameter uri

    optional, redis uri

    Parameter opts

    redis connection options {RedisAdapter} adapter

    Modifiers

    • @public

Classes

class RedisAdapter

class RedisAdapter extends Adapter {}

    constructor

    constructor(nsp: any, uri: string, opts?: Partial<RedisAdapterOptions>);
    • Adapter constructor.

      Parameter nsp

      the namespace

      Parameter uri

      the url of the Redis server

      Parameter opts

      the options for both the Redis adapter and the Redis client

      Modifiers

      • @public

    property pubClient

    readonly pubClient: any;

      property requestsTimeout

      readonly requestsTimeout: number;

        property subClient

        readonly subClient: any;

          property uid

          readonly uid: any;

            method addSockets

            addSockets: (opts: BroadcastOptions, rooms: Room[]) => void;

              method allRooms

              allRooms: () => Promise<Set<Room>>;
              • Gets the list of all rooms (across every node)

                Modifiers

                • @public

              method broadcast

              broadcast: (packet: any, opts: BroadcastOptions) => void;
              • Broadcasts a packet.

                Parameter packet

                packet to emit

                Parameter opts

                options

                Modifiers

                • @public

              method delSockets

              delSockets: (opts: BroadcastOptions, rooms: Room[]) => void;

                method disconnectSockets

                disconnectSockets: (opts: BroadcastOptions, close: boolean) => void;

                  method fetchSockets

                  fetchSockets: (opts: BroadcastOptions) => Promise<any[]>;

                    method remoteDisconnect

                    remoteDisconnect: (id: SocketId, close?: boolean) => Promise<void>;
                    • Makes the socket with the given id to be forcefully disconnected

                      Parameter id

                      socket id

                      Parameter close

                      if true, closes the underlying connection

                      Modifiers

                      • @public

                    method remoteJoin

                    remoteJoin: (id: SocketId, room: Room) => Promise<void>;
                    • Makes the socket with the given id join the room

                      Parameter id

                      socket id

                      Parameter room

                      room name

                      Modifiers

                      • @public

                    method remoteLeave

                    remoteLeave: (id: SocketId, room: Room) => Promise<void>;
                    • Makes the socket with the given id leave the room

                      Parameter id

                      socket id

                      Parameter room

                      room name

                      Modifiers

                      • @public

                    method sockets

                    sockets: (rooms: Set<Room>) => Promise<Set<SocketId>>;
                    • Gets a list of sockets by sid.

                      Parameter rooms

                      the explicit set of rooms to check.

                    Interfaces

                    interface RedisAdapterOptions

                    interface RedisAdapterOptions {}

                      property key

                      key: string;
                      • the name of the key to pub/sub events on as prefix socket.io

                      property pubClient

                      pubClient: any;
                      • the redis client to publish events on

                      property requestsTimeout

                      requestsTimeout: number;
                      • after this timeout the adapter will stop waiting from responses to request 5000

                      property subClient

                      subClient: any;
                      • the redis client to subscribe to events on

                      Package Files (1)

                      Dependencies (5)

                      Dev Dependencies (12)

                      Peer Dependencies (0)

                      No peer dependencies.

                      Badge

                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/socket.io-redis.

                      • Markdown
                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/socket.io-redis)
                      • HTML
                        <a href="https://www.jsdocs.io/package/socket.io-redis"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>