/** * Copyright 2025 Angus.Fenying * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type * as $Net from 'node:net'; import { Writable, WritableOptions } from 'node:stream'; import type * as dL from '../Decl'; import * as cL from '../Constants'; export declare class WsFrameWriter { private readonly _encoder; maskKey: Buffer | boolean; protected _socket: $Net.Socket | null; constructor(socket?: $Net.Socket | null); setSocket(socket: $Net.Socket): void; /** * Build and write a WebSocket frame * * @param opcode The opcode of the frame * @param isFin Is this the final frame? * @param payload The payload of the frame * @param callback A callback to be called when the frame is written * * @returns Return false if the socket buffer is full, needs to wait for draining. */ writeArray(opcode: cL.EOpcode, isFin: boolean, payload: Array, callback: dL.IErrorCallback): boolean; /** * Build and write a WebSocket frame * * @param opcode The opcode of the frame * @param isFin Is this the final frame? * @param payload The payload of the frame * @param callback A callback to be called when the frame is written * * @returns Return false if the socket buffer is full, needs to wait for draining. */ write(opcode: cL.EOpcode, isFin: boolean, payload: Buffer | string, callback: dL.IErrorCallback): boolean; } export declare class WsMessageWriter extends Writable implements dL.IMessageWriter { readonly opcode: cL.EOpcode; readonly maxMessageSize: number; protected readonly _writer: WsFrameWriter; private _sentBytes; constructor(opcode: cL.EOpcode, maxMessageSize: number, _writer: WsFrameWriter, opts?: WritableOptions); _write(chunk: Buffer | string, _encoding: BufferEncoding, callback: dL.IErrorCallback): void; _final(callback: dL.IErrorCallback): void; } //# sourceMappingURL=MessageWriter.d.ts.map