import { ReceiverConfig } from '../main/config/definitions/parts/receiverConfig'; import BackErrorBag from "./BackErrorBag"; import Socket from './Socket'; import Packet from './Packet'; import Component from './component/Component'; import { ConsumeInputFunction } from '../main/input/inputClosureCreator'; import { CompHandleMiddlewareInvoker } from '../main/compHandleMiddleware/compHandleMiddlewareUtils'; import { NormalAccessCustomFunction } from '../main/config/definitions/parts/accessConfigs'; import { PreparedProcessChain } from '../main/processChain/prepareProcessChainConfig'; /** * The Receiver is a component that can be compared with the controller component, * with the only difference that the Receiver * receives packages but not send a response back to the client. * That can give you performance benefits. * The Receiver is useful if you not want to return a result and * the status of the process does not matter on the client-side. */ export default class Receiver extends Component { /** * **Not override this** * Used internally. */ readonly _preparedData: ReceiverPreparedData; constructor(identifier: string, preparedData: ReceiverPreparedData, apiLevel: number | undefined); /** * @description * This property is used for getting the configuration of this receiver. */ static readonly config: ReceiverConfig; /** * @description * Gets invoked when the receiver receives a transmit and input is correct. * This method will only be invoked when the beforeHandle method has not thrown an error. * @param socket * @param input * @param packet * @throws * All errors thrown in this method will only be handled on the server-side * and are not send back to the client. * Because the receiver does not send a response back. */ protected handle(socket: Socket, input: any, packet: Packet): Promise | void; /** * @description * Gets invoked when the receiver receives a transmit with invalid input. * @param socket * @param rawInput * Notice that you will get the raw input means only * the data the user has sent without processed by the models. * @param packet * @param backErrorBag * @throws * All errors thrown in this method will only be handled on the server-side * and are not send back to the client. * Because the receiver does not send a response back. */ protected invalidInput(socket: Socket, rawInput: any, packet: Packet, backErrorBag: BackErrorBag): Promise | void; /** * Decorator for set the Receiver config. * But notice that when you use the decorator * that you cannot set the config property by yourself. * @param receiverConfig * @example * @Controller.Config({}); */ static Config(receiverConfig: ReceiverConfig): (target: typeof Receiver) => void; } export declare type ReceiverClass = (new (...args: any[]) => Receiver) & { config: ReceiverConfig; prototype: Receiver; }; export interface ReceiverPreparedData extends PreparedProcessChain { receiverConfig: ReceiverConfig; checkAccess: NormalAccessCustomFunction; handleMiddlewareInvoke: CompHandleMiddlewareInvoker; consumeInput: ConsumeInputFunction; }