@cutls/megalodon
Version:
Mastodon, Pleroma, Misskey API client for node.js and browser
40 lines (39 loc) • 1.24 kB
TypeScript
/// <reference types="node" />
/// <reference types="ws" />
import WS from 'isomorphic-ws'
import { EventEmitter } from 'events'
import { WebSocketInterface } from '../megalodon'
type MisskeyTL = 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list'
export default class WebSocket extends EventEmitter implements WebSocketInterface {
url: string
channel: MisskeyTL
parser: Parser
headers: {
[key: string]: string
}
listId: string | null
private _accessToken
private _reconnectInterval
private _reconnectMaxAttempts
private _reconnectCurrentAttempts
private _connectionClosed
private _client
private _channelID
constructor(url: string, channel: MisskeyTL, accessToken: string, listId: string | undefined, userAgent: string)
start(): void
private baseUrlToHost
private _startWebSocketConnection
stop(): void
subscribe(channelID: string, stream: string, add?: Record<string, string>): void
private _resetConnection
private _resetRetryParams
private _connect
private _channel
private _reconnect
private _clearBinding
private _bindSocket
private _setupParser
}
export declare class Parser extends EventEmitter {
parse(data: WS.Data, isBinary: boolean, _channelID: string): void
}