import Emittery from 'emittery'; import { BufferLike, Nullable } from '@mlytics/core-ts/core/type/basic'; import { Channel, ChannelHub, Condition } from '@mlytics/core-ts/core/util/future'; import { AbstractBrokerInfo, SpecBroker } from '../../base/broker/broker'; import { Centrifuge } from './base/centrifuge/centrifuge'; import * as ctxs from './base/centrifuge/model/context'; interface SpecTrackerBroker extends SpecBroker, SpecConstraintTrackerBroker { info: TrackerBrokerInfo; } interface SpecConstraintTrackerBroker { info: TrackerBrokerInfo; isAvailable: boolean; } declare class TrackerBroker implements SpecTrackerBroker { protected readonly _uri: string; protected _info: TrackerBrokerInfo; protected _client: TrackerClient; protected _condition: Condition; protected _eventHub: ChannelHub; protected _messageHub: ChannelHub; protected _deliverChannel: Channel; protected _receiveChannel: Channel; constructor(_uri: string); get info(): TrackerBrokerInfo; get condition(): Condition; get eventHub(): ChannelHub; get messageHub(): ChannelHub; get deliverChannel(): Channel; get receiveChannel(): Channel; get serverChannelID(): string; get isActivated(): boolean; get isConnected(): boolean; get isAvailable(): boolean; activate(): Promise; deactivate(): Promise; sendMessage(data: BufferLike): Promise; commitMessage(data: BufferLike): Promise; protected _bindEvents(): Promise; protected _openEventHub(): Promise; } declare class TrackerBrokerInfo extends AbstractBrokerInfo { protected _peerID: string; get id(): Nullable; } declare class TrackerClient extends Emittery { protected readonly _uri: string; protected _state: TrackerState; protected _centrifuge: Centrifuge; protected _serverChannelID: string; constructor(_uri: string); get state(): SpecTrackerState; get serverChannelID(): string; send(data: BufferLike): Promise; open(): Promise; close(): Promise; protected _bindCentrifuge(): void; protected _renewToken(): Promise; protected _onState(ctx: ctxs.StateContext): Promise; protected _onConnecting(ctx: ctxs.ConnectingContext): Promise; protected _onConnected(ctx: ctxs.ConnectedContext): Promise; protected _onDisconnected(ctx: ctxs.DisconnectedContext): Promise; protected _onSubscribing(ctx: ctxs.SubscribingContext): Promise; protected _onSubscribed(ctx: ctxs.SubscribedContext): Promise; protected _onUnsubscribed(ctx: ctxs.UnsubscribedContext): Promise; protected _onJoin(ctx: ctxs.JoinContext): Promise; protected _onLeave(ctx: ctxs.LeaveContext): Promise; protected _onPublication(ctx: ctxs.PublicationContext): Promise; protected _onMessage(ctx: ctxs.MessageContext): Promise; protected _onError(ctx: ctxs.ErrorContext): Promise; } declare class CentrifugeEvent { static readonly STATE = "state"; static readonly CONNECTING = "connecting"; static readonly CONNECTED = "connected"; static readonly DISCONNECTED = "disconnected"; static readonly SUBSCRIBING = "subscribing"; static readonly SUBSCRIBED = "subscribed"; static readonly UNSUBSCRIBED = "unsubscribed"; static readonly JOIN = "join"; static readonly LEAVE = "leave"; static readonly PUBLICATION = "publication"; static readonly MESSAGE = "message"; static readonly ERROR = "error"; } declare class TrackerEvent extends CentrifugeEvent { static readonly TERMINATED = "terminated"; static readonly SERVER_DATA = "server_data"; static readonly SPREAD_DATA = "spread_data"; } interface SpecTrackerState { isInitial: boolean; isConnecting: boolean; isConnected: boolean; isDestroyed: boolean; } declare class TrackerState implements SpecTrackerState { protected _name: TrackerStateName; constructor(); get isInitial(): boolean; get isConnecting(): boolean; get isConnected(): boolean; get isDestroyed(): boolean; toInitial(): void; toConnecting(): void; toConnected(): void; toDestroyed(): void; } declare class TrackerStateName { static readonly INITIAL = "initial"; static readonly CONNECTING = "connecting"; static readonly CONNECTED = "connected"; static readonly DESTROYED = "destroyed"; } export { SpecTrackerBroker, SpecConstraintTrackerBroker, TrackerBroker, TrackerBrokerInfo, TrackerEvent };