UNPKG

dlovely-websocket

Version:

WebSocket For Dlovely

45 lines (44 loc) 1.86 kB
/// <reference types="@types/node/net" /> /// <reference types="@types/node/tls" /> /// <reference types="@types/node/http" /> /// <reference types="@types/node/buffer" /> /// <reference types="@types/node/events" /> import { EventEmitter } from 'events'; import type { IncomingHttpHeaders } from 'http'; import type { Socket } from 'net'; import type { TLSSocket } from 'tls'; import { OutStream } from './OutStream'; import type { SocketApp } from './SocketApp'; export declare class AppConnection extends EventEmitter { readonly token: string; readonly server: SocketApp; readonly socket: Socket | TLSSocket; private key?; readonly headers: IncomingHttpHeaders; private protocol?; private protocols?; constructor(token: string, socket: Socket | TLSSocket, server: SocketApp, onConnect: () => void); extraParams: SocketApp.ConnectionExtraParams; sendSign(sign: string, data?: string | object, callback?: (err?: Error) => void): boolean; sendText(str: string, callback?: (err?: Error) => void): boolean; sendBinary(data: Buffer, callback?: (err?: Error) => void): boolean; send(data: string | Buffer, callback?: (err?: Error) => void): void; close(code: number, reason?: string): void; private buffer; private doRead; private readHandshake; private answerHandshake; private readHeaders; private frameBuffer?; outStream?: OutStream | string; private extractFrame; private processFrame; private processCloseFrame; readyState: AppConnection['CONNECTING'] | AppConnection['OPEN'] | AppConnection['CLOSING'] | AppConnection['CLOSED']; readonly CONNECTING = 0; readonly OPEN = 1; readonly CLOSING = 2; readonly CLOSED = 3; static binaryFragmentation: number; static maxBufferLength: number; }