@types/socket.io.users
TypeScript icon, indicating that this package has built-in type declarations

0.0.35 • Public • Published

Installation

npm install --save @types/socket.io.users

Summary

This package contains type definitions for socket.io.users (https://github.com/nodets/socket.io.users).

Details

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

index.d.ts

import { EventEmitter } from "events";
import { Application } from "express";
import { SessionOptions } from "express-session";
import SocketIO = require("socket.io");

declare var CONNECTION_EVENTS: string[];
declare var Middleware: () => (socket: SocketIO.Socket, next: () => any) => void;
declare var Session: (app: Application, options?: SessionOptions) => void;

type SocketUserList = {
    [namespace: string]: Users;
};

declare class Namespaces {
    private static socketUsersList: any;
    static attach(namespace: string, socketUsersObj: Users): void;
    static get(namespace: string): Users;
}

declare class User {
    id: string | number;
    socket: SocketIO.Socket;
    sockets: SocketIO.Socket[];
    rooms: string[];
    ip: string;
    remoteAddresses: string[];
    store: any;
    attach(socket: SocketIO.Socket): void;
    detachSocket(socket: SocketIO.Socket): void;
    detach(): void;
    join(room: string): boolean;
    leave(room: string): void;
    leaveAll(): void;
    /** same as in, checks if this user is inside a room */
    belong(room: string): boolean;
    /** same as belong, checks if this user is inside a room  */
    in(room: string): boolean;
    set(key: string, value: any, callback?: () => void): void;
    get: (key: string) => any;
    toString(): string;
    emit(...args: any[]): void;
    to(room: string): SocketIO.Socket;
}

declare class Users extends EventEmitter {
    namespace: string;
    users: User[];
    constructor(namespace?: string);
    static of(namespace?: string): Users;
    takeId: (request: any) => string | number;
    create(socket: SocketIO.Socket): User;
    getById(id: string | number): User;
    get(socket: SocketIO.Socket): User;
    list(): User[];
    size(): number;
    push(_user: User): void;
    add(socket: SocketIO.Socket): User;
    indexOf(user: User): number;
    remove(user: User): void;
    room(room: string): User[];
    in(room: string): User[];
    from(room: string): User[];
    update(user: User): void;
    emitAll(...args: any[]): void;
    registerSocketEvents(currentUser: User): void;
}

Additional Details

Credits

These definitions were written by Makis Maropoulos.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/socket.io.users

Weekly Downloads

2

Version

0.0.35

License

MIT

Unpacked Size

7.09 kB

Total Files

5

Last publish

Collaborators

  • types