UNPKG

laravel-echo

Version:

Laravel Echo library for beautiful Pusher, Socket.IO, and Mercure integration

78 lines (77 loc) • 2.79 kB
import type Pusher from "pusher-js"; import type { Options as PusherJsOptions } from "pusher-js"; import { PusherChannel, PusherEncryptedPrivateChannel, PusherPresenceChannel, PusherPrivateChannel } from "../channel"; import type { BroadcastDriver, ConnectionStatus } from "../echo"; import { Connector, type EchoOptionsWithDefaults } from "./connector"; type AnyPusherChannel = PusherChannel<BroadcastDriver> | PusherPrivateChannel<BroadcastDriver> | PusherEncryptedPrivateChannel<BroadcastDriver> | PusherPresenceChannel<BroadcastDriver>; export type PusherOptions<TBroadcastDriver extends BroadcastDriver> = EchoOptionsWithDefaults<TBroadcastDriver> & { key: string; Pusher?: typeof Pusher; } & PusherJsOptions; /** * This class creates a connector to Pusher. */ export declare class PusherConnector<TBroadcastDriver extends BroadcastDriver> extends Connector<TBroadcastDriver, PusherChannel<TBroadcastDriver>, PusherPrivateChannel<TBroadcastDriver>, PusherPresenceChannel<TBroadcastDriver>> { /** * The Pusher instance. */ pusher: Pusher; /** * All of the subscribed channel names. */ channels: Record<string, AnyPusherChannel>; options: PusherOptions<TBroadcastDriver>; /** * Create a fresh Pusher connection. */ connect(): void; /** * Sign in the user via Pusher user authentication (https://pusher.com/docs/channels/using_channels/user-authentication/). */ signin(): void; /** * Listen for an event on a channel instance. */ listen(name: string, event: string, callback: CallableFunction): AnyPusherChannel; /** * Get a channel instance by name. */ channel(name: string): AnyPusherChannel; /** * Get a private channel instance by name. */ privateChannel(name: string): PusherPrivateChannel<TBroadcastDriver>; /** * Get a private encrypted channel instance by name. */ encryptedPrivateChannel(name: string): PusherEncryptedPrivateChannel<TBroadcastDriver>; /** * Get a presence channel instance by name. */ presenceChannel(name: string): PusherPresenceChannel<TBroadcastDriver>; /** * Leave the given channel, as well as its private and presence variants. */ leave(name: string): void; /** * Leave the given channel. */ leaveChannel(name: string): void; /** * Get the socket ID for the connection. */ socketId(): string; /** * Get the current connection status. */ connectionStatus(): ConnectionStatus; /** * Subscribe to connection status changes. */ onConnectionChange(callback: (status: ConnectionStatus) => void): () => void; /** * Disconnect Pusher connection. */ disconnect(): void; } export {};