import dotenv from 'dotenv'; import { FisAppActor, FisMessage, TransmissionMessage } from "../interface/transport.interface"; import { ConnectionAdapter } from "./connector.base"; import { AdaptorTransmissionRole, ConnectionState, TransmitterConnectionAdapter as TransmitterConnectionAdapterInterface, Transport, TransportMessage, TransportService } from '../interface/connector.interface'; import { BehaviorSubject, Observable, Observer } from 'rxjs'; import { v4 as uuidv4 } from 'uuid' import { WebsocketTransportService } from '../transport/websocket'; import { HttpTransportService } from '../transport/http'; dotenv.config(); /* This transport manager will be instantiating the necessary transport to deal with tranmission and receiving from different receivers So how?: */ export class TransmitterConnectionAdapter extends ConnectionAdapter implements TransmitterConnectionAdapterInterface { connectionStateBus: BehaviorSubject = new BehaviorSubject('OFFLINE' as ConnectionState) // this cannot work, because there will be alot of clients connected presumably constructor(transportService: TransportService) { super() // logic here } emitStream(message: TransmissionMessage): void { throw new Error('Method not implemented.'); } emit(message: TransmissionMessage): void { (this.connector as TransportService).emit({ id: uuidv4(), dateCreated: new Date(), transport: Transport.Websocket, target: message.receiverId, payload: message.payload } as TransportMessage) } }