import { EnlaceServer } from "../server.ts" ; import { Router } from "../router.ts" ; import { Client } from "../../client.ts" ; import { GenericEndpointInput } from "../endpoint/endpoint_input.ts" ; import { AdaptorConfig } from "./adaptor_config.ts" ; export abstract class Adaptor { /**
     * This value is empty when the Adaptor is not added to EnlaceServer.
     */ protected config ! : AdaptorConfig ; public get isAssociatedWithServer ( ) : boolean { return true ; } /**
     * Router instance contained in the adapter.
     */ public router : Router = new Router ( this ) ; /**
     * A string value indicates network protocol of this Adaptor. (like 'HTTP/1.1')
     */ public static protocol : string = 'None' ; /**
     * A map table store the relationship between clients and their own input.
     * Subclasses need to maintain themselves.
     */ protected clientToInput : Map < Client , GenericEndpointInput > = new Map ( ) ; param server param config attachOnServer ( server , config ) { this . config = config ; } param client param content public abstract sendToClient ( client , content ) ; param input param client public didReceiveContent : ( input : GenericEndpointInput , client : Client ) => void = ( ) => { } ; /**
     * Life cycle callback called when the adapter is already on the
     * server and starts listening for requests. Called by EnlaceServer.
     */ protected onStart ( ) { } /**
     * Life cycle callback called when the adapter has stopped listening
     * for requests or is no longer associated with any server. Called by
     * EnlaceServer.
     */ protected onDispose ( ) { } }