peer

  • Version 1.0.2
  • Published
  • 203 kB
  • 7 dependencies
  • MIT license

Install

npm i peer
yarn add peer
pnpm add peer

Overview

PeerJS server component

Index

Functions

function ExpressPeerServer

ExpressPeerServer: (
server: https.Server | http.Server,
options?: Partial<IConfig>
) => express.Express & PeerServerEvents;

    function PeerServer

    PeerServer: (
    options?: Partial<IConfig>,
    callback?: (server: https.Server | http.Server) => void
    ) => express.Express & PeerServerEvents;

      Interfaces

      interface IClient

      interface IClient {}

        method getId

        getId: () => string;

          method getLastPing

          getLastPing: () => number;

            method getSocket

            getSocket: () => WebSocket | null;

              method getToken

              getToken: () => string;

                method send

                send: <T>(data: T) => void;

                  method setLastPing

                  setLastPing: (lastPing: number) => void;

                    method setSocket

                    setSocket: (socket: WebSocket | null) => void;

                      interface IConfig

                      interface IConfig {}

                        property alive_timeout

                        readonly alive_timeout: number;

                          property allow_discovery

                          readonly allow_discovery: boolean;

                            property cleanup_out_msgs

                            readonly cleanup_out_msgs: number;

                              property concurrent_limit

                              readonly concurrent_limit: number;

                                property corsOptions

                                readonly corsOptions: CorsOptions;

                                  property createWebSocketServer

                                  readonly createWebSocketServer?: (options: ServerOptions) => WebSocketServer;

                                    property expire_timeout

                                    readonly expire_timeout: number;

                                      property generateClientId

                                      readonly generateClientId?: () => string;

                                        property host

                                        readonly host: string;

                                          property key

                                          readonly key: string;

                                            property path

                                            readonly path: string;

                                              property port

                                              readonly port: number;

                                                property proxied

                                                readonly proxied: boolean | string;

                                                  property ssl

                                                  readonly ssl?: {
                                                  key: string;
                                                  cert: string;
                                                  };

                                                    interface IMessage

                                                    interface IMessage {}

                                                      property dst

                                                      readonly dst: string;

                                                        property payload

                                                        readonly payload?: string | undefined;

                                                          property src

                                                          readonly src: string;

                                                            property type

                                                            readonly type: MessageType;

                                                              interface PeerServerEvents

                                                              interface PeerServerEvents {}

                                                                method on

                                                                on: {
                                                                (event: 'connection', listener: (client: IClient) => void): this;
                                                                (
                                                                event: 'message',
                                                                listener: (client: IClient, message: IMessage) => void
                                                                ): this;
                                                                (event: 'disconnect', listener: (client: IClient) => void): this;
                                                                (event: 'error', listener: (client: Error) => void): this;
                                                                };

                                                                  Enums

                                                                  enum MessageType

                                                                  enum MessageType {
                                                                  OPEN = 'OPEN',
                                                                  LEAVE = 'LEAVE',
                                                                  CANDIDATE = 'CANDIDATE',
                                                                  OFFER = 'OFFER',
                                                                  ANSWER = 'ANSWER',
                                                                  EXPIRE = 'EXPIRE',
                                                                  HEARTBEAT = 'HEARTBEAT',
                                                                  ID_TAKEN = 'ID-TAKEN',
                                                                  ERROR = 'ERROR',
                                                                  }

                                                                    member ANSWER

                                                                    ANSWER = 'ANSWER'

                                                                      member CANDIDATE

                                                                      CANDIDATE = 'CANDIDATE'

                                                                        member ERROR

                                                                        ERROR = 'ERROR'

                                                                          member EXPIRE

                                                                          EXPIRE = 'EXPIRE'

                                                                            member HEARTBEAT

                                                                            HEARTBEAT = 'HEARTBEAT'

                                                                              member ID_TAKEN

                                                                              ID_TAKEN = 'ID-TAKEN'

                                                                                member LEAVE

                                                                                LEAVE = 'LEAVE'

                                                                                  member OFFER

                                                                                  OFFER = 'OFFER'

                                                                                    member OPEN

                                                                                    OPEN = 'OPEN'

                                                                                      Package Files (1)

                                                                                      Dependencies (7)

                                                                                      Dev Dependencies (24)

                                                                                      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/peer.

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