///
import { RemoteInfo } from 'node:dgram';
import { IInputProvider, ILogger } from '../../types';
import { ICoreUdpRequest } from '../types/udp-types';
export interface ICoreInputUdpProviderOptions {
inputContextCallback?: (req: ICoreUdpRequest) => void;
}
export default class CoreInputUdpProvider implements IInputProvider {
private alreadyRegistered;
private logger?;
private udpPorts;
private udpServer;
private applyInputCb;
private options;
/**
* constructor
*
* This function sets class level variables.
*
* @param udpPorts - an array of numbers, the ports to start HTTP servers on.
* @param logger - a logger instance to use for logging.
* @param options
**/
constructor(udpPorts: Array, logger: ILogger | undefined, options: ICoreInputUdpProviderOptions);
/**
* registerHandler
* This is called by the rules engine when it starts. This function sets up the udp listener
*
* Do this by...
* 1. Set the rules engine apply function for use later
* 2. If we are not already setup then loop over every configured port
* 3. for every configured port create udp socket
* 4. for every configured port bind socket
* 5. for every configured port setup listening event
* 6. for every configured port setup message handler
* 7. for every configured port save the socket for later removal if we ever unregisterInput
*
* @param applyInputCb - a handler that will be called when there is input. It should be passed input and context.
* @returns Promise
**/
registerInput(applyInputCb: (input: any, context: any) => Promise): Promise;
/**
* udpHandler
* Handle the udp message
*
* does this by
* 1. Build input facts
* 2. Optionaly call inputContextCallback if it is defined to build a context
* 3. Pass input facts and context to the rules engine
*/
udpHandler(msg: Buffer, rinfo: RemoteInfo): Promise;
unregisterInput(): Promise;
}