///
///
///
import * as Net from 'net';
import type { ProtocolRequest, ProtocolResponse } from '../events/ProtocolEvent';
import PluginInterface from '../PluginInterface';
import type { ProtocolServerPlugin } from './DebugProtocolServerPlugin';
export declare const DEBUGGER_MAGIC = "bsdebug";
/**
* A class that emulates the way a Roku's DebugProtocol debug session/server works. This is mostly useful for unit testing,
* but might eventually be helpful for an off-device emulator as well
*/
export declare class DebugProtocolServer {
options?: DebugProtocolServerOptions;
constructor(options?: DebugProtocolServerOptions);
private logger;
/**
* Indicates whether the client has sent the magic string to kick off the debug session.
*/
private isHandshakeComplete;
private buffer;
/**
* The server
*/
private server;
/**
* Once a client connects, this is a reference to that client
*/
private client;
/**
* A collection of plugins that can interact with the server at lifecycle points
*/
plugins: PluginInterface;
/**
* A queue for processing the incoming buffer, every transmission at a time
*/
private bufferQueue;
get controlPort(): number;
private _port;
/**
* Run the server. This opens a socket and listens for a connection.
* The promise resolves when the server has started listening. It does NOT wait for a client to connect
*/
start(): Promise;
stop(): Promise;
destroy(): Promise;
/**
* Given a buffer, find the request that matches it
*/
static getRequest(buffer: Buffer, allowHandshake: boolean): ProtocolRequest;
private getResponse;
/**
* Process a single request.
* @returns true if successfully processed a request, and false if not
*/
private process;
/**
* Send a response from the server to the client. This involves writing the response buffer to the client socket
*/
private sendResponse;
/**
* Send an update from the server to the client. This can be things like ALL_THREADS_STOPPED
*/
sendUpdate(update: ProtocolResponse): Promise;
/**
* An event emitter used for all of the events this server emitts
*/
private emitter;
on(eventName: 'before-send-response', callback: (event: T) => void): any;
on(eventName: 'after-send-response', callback: (event: T) => void): any;
on(eventName: 'client-connected', callback: (event: T) => void): any;
on(eventName: string, callback: (data: T) => void): any;
/**
* Subscribe to an event exactly one time. This will fire the very next time an event happens,
* and then immediately unsubscribe
*/
once(eventName: string): Promise;
emit(eventName: 'before-send-response', event: T): T;
emit(eventName: 'after-send-response', event: T): T;
emit(eventName: 'client-connected', event: T): T;
/**
* The magic string used to kick off the debug session.
* @default "bsdebug"
*/
private get magic();
}
export interface DebugProtocolServerOptions {
/**
* The magic that is sent as part of the handshake
*/
magic?: string;
/**
* The port to use for the primary communication between this server and a client
*/
controlPort?: number;
/**
* A specific host to listen on. If not specified, all hosts are used
*/
host?: string;
}