/** * An object representing a channel or channel resource. * Site visitors can subscribe to a channel or channel resource to receive the * messages that are published on it. When site visitors subscribe to a channel, they do not * receive messages published to a resource on that same channel. Similarly, * when site visitors subscribe to a channel resource, they do not * receive messages published to that same channel without a specified resource. * Channel resources inherit their parent channel's permissions, unless specified * otherwise. */ export interface Channel { /** * Channel name. Cannot exceed 140 characters. * @requiredField name */ name: string; /** * ID of a specific channel resource. */ resourceId?: string; } /** * An object representing an error. */ export interface Error { /** * Error code. * * One of: * * + `1`: Connection error * + `2`: Subscription error (error will also include a channel value) * + `3`: Bad input * @requiredField errorCode */ errorCode: number; /** * Error message. * @requiredField message */ message: string; /** * Channel related to the error. * @servicePath wix-realtime-frontend.Channel */ channel?: Channel; } /** * An object representing a published message. */ export interface Message { /** * Message payload. * Max: 10kb * @requiredField payload */ payload: any; /** * Message publisher, if sent. * @servicePath wix-realtime-frontend.Publisher */ publisher?: Publisher; } /** * An object representing a publisher. */ export interface Publisher { /** * ID of the publisher. * @requiredField id */ id: string; } /** * An object containing options to be used when unsubscribing from a * channel or channel resource. */ export interface UnsubscribeOptions { /** * The channel, and optionally the resource, to * unsubscribe from. Use this property when unsubscribing from all subscriptions to a channel * or channel resource. * @servicePath wix-realtime-frontend.Channel */ channel?: Channel; /** * ID of the subscription to unsubscribe from. Use this * property when unsubscribing from one of multiple subscriptions to a channel or channel * resource. */ subscriptionId?: string; } /** * undefined * * Handles connections. */ export type ConnectionHandler = () => void; /** * undefined * * Handles disconnections. */ export type DisconnectionHandler = () => void; /** * undefined * * Handles realtime errors. * @param error - The error that occurred. * @requiredField error * @servicePath wix-realtime-frontend.Error */ export type ErrorHandler = (error: Error) => void; /** * undefined * * Handles a message published to a channel or channel resource. * @param message - The message that was published. * @requiredField message * @servicePath wix-realtime-frontend.Message * @param channel - The channel the message was published on. * @requiredField channel * @servicePath wix-realtime-frontend.Channel */ export type MessageHandler = (message: Message, channel: Channel) => void;