Jelajahi Sumber

updated with the latest spec yet again

Enzo 3 minggu lalu
induk
melakukan
2ab9bad121

+ 58 - 0
src/connector/connector.base.ts

@@ -0,0 +1,58 @@
+import { Observable, Observer, Subject, Subscriber, Unsubscribable } from "rxjs";
+import dotenv from 'dotenv';
+import { AdaptorTransmissionRole, ConnectionAdaptorBase, ConnectionState } from "../interface/connector.interface";
+import { Bus, FisAppActor, FisMessage } from "../interface/transport.interface";
+
+dotenv.config();
+/* This transport manager will be instantiating the necessary transport to deal with tranmission and receiving from different receivers
+So how?: */
+export class ConnectionAdapter implements FisAppActor, ConnectionAdaptorBase {
+    incomingMessageBus: Subject<any> = new Subject()
+    outgoingMessageBus: Subject<any> = new Subject()
+    connector: any;
+    connectorProfile: any;
+    connectionState!: ConnectionState;
+    connectionStateBus!: Observable<ConnectionState>;
+    adaptorTransmissionRole!: AdaptorTransmissionRole;
+
+    constructor(port?: number, url?: string) {
+        if (!port && !url) console.error(`No role has assigned for transport service due to lack of information provided!`)
+    }
+
+    getMessageBus(bus: Bus): Observable<any> {
+        throw new Error("Method not implemented.");
+    }
+
+    subscribeConnectionState(): Observable<ConnectionState> {
+        throw new Error("Method not implemented.");
+    }
+    publishConnectionState(): void {
+        throw new Error("Method not implemented.");
+    }
+    connect(): void {
+        throw new Error("Method not implemented.");
+    }
+    disconnect(): void {
+        throw new Error("Method not implemented.");
+    }
+    send(message: any): Observable<any> {
+        throw new Error(`Method not implemented.`)
+    }
+    emit(message: any): void {
+        // logic here
+    }
+    emitStream(message: any): void {
+        throw new Error("Method not implemented.");
+    }
+    subscribeMessages(messageFilter: any): Observable<any> {
+        throw new Error("Method not implemented.");
+    }
+    subscribe(subscriber: Subscriber<any>): Unsubscribable {
+        throw new Error("Method not implemented.");
+    }
+
+
+
+}
+
+

+ 23 - 0
src/connector/connector.manager.ts

@@ -0,0 +1,23 @@
+import { v4 as uuidv4 } from 'uuid'
+import { ConnectionManager as ConnectionManagerInterface, RequestResponseConnectionAdapter } from "../interface/connector.interface"
+import { TransmitterConnectionAdapter } from './connector.transmitter'
+import { ReceiverConnectionAdapter } from './connector.receiver'
+import { TransmissionProfile } from '../interface/transport.interface'
+
+export class ConnectionManager implements ConnectionManagerInterface {
+
+    constructor(transmissionProfile: TransmissionProfile) {
+        // logic here
+    }
+    getRequestResponseConnectionAdapter(): RequestResponseConnectionAdapter {
+        throw new Error('Method not implemented.')
+    }
+    getTransmitterConnectionAdapter(): TransmitterConnectionAdapter {
+        throw new Error("Method not implemented.")
+    }
+    getReceiverConnectionAdapter(): ReceiverConnectionAdapter {
+        throw new Error("Method not implemented.")
+    }
+
+
+}

+ 3 - 3
src/connector/receiver.connector.ts → src/connector/connector.receiver.ts

@@ -1,14 +1,14 @@
 import dotenv from 'dotenv';
 import { FisAppActor, FisMessage } from "../interface/transport.interface";
-import { ConnectionAdapter } from "./connector";
+import { ConnectionAdapter } from "./connector.base";
 import { ReceiverConnectionAdapterBase } from "../interface/connector.interface";
 
 dotenv.config();
 /* This transport manager will be instantiating the necessary transport to deal with tranmission and receiving from different receivers
 So how?: */
-export class ReceiverConnectionAdapter extends ConnectionAdapter implements FisAppActor, ReceiverConnectionAdapterBase<any> {
+export class ReceiverConnectionAdapter extends ConnectionAdapter implements FisAppActor, ReceiverConnectionAdapterBase {
 
-    constructor() {
+    constructor(url: string) {
         super()
         // logic here
     }

+ 2 - 2
src/connector/transmitter.connector.ts → src/connector/connector.transmitter.ts

@@ -1,12 +1,12 @@
 import dotenv from 'dotenv';
 import { FisAppActor, FisMessage } from "../interface/transport.interface";
-import { ConnectionAdapter } from "./connector";
+import { ConnectionAdapter } from "./connector.base";
 import { TransmitterConnectionAdapterBase } from '../interface/connector.interface';
 
 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 FisAppActor, TransmitterConnectionAdapterBase<any> {
+export class TransmitterConnectionAdapter extends ConnectionAdapter implements FisAppActor, TransmitterConnectionAdapterBase {
 
     constructor(port: number) {
         super()

+ 0 - 178
src/connector/connector.ts

@@ -1,178 +0,0 @@
-import { Observable, Observer, Subject, Subscriber, Unsubscribable } from "rxjs";
-import dotenv from 'dotenv';
-import { v4 as uuidv4 } from 'uuid';
-import { ITransportReceiving, ITransportSuper, ITransportTransmitting, ReceiverProfile, TransportEventNotification, TransportManagerEventNotification, TransportManagerInterface, TransportMessage, TransportSettings, TransportType } from "../interface/ITransport.interface";
-import { AdaptorTransmissionRole, ConnectionAdaptorBase, ConnectionState } from "../interface/connector.interface";
-import { FisAppActor, FisMessage } from "../interface/transport.interface";
-
-dotenv.config();
-/* This transport manager will be instantiating the necessary transport to deal with tranmission and receiving from different receivers
-So how?: */
-export class ConnectionAdapter implements FisAppActor, ConnectionAdaptorBase<any> {
-    incomingMessageBus: Subject<any> = new Subject()
-    outgoingMessageBus: Subject<any> = new Subject()
-    connector: any;
-    connectorProfile: any;
-    connectionState!: ConnectionState;
-    connectionStateBus!: Observable<ConnectionState>;
-    adaptorTransmissionRole!: AdaptorTransmissionRole;
-
-    // For Manager, TBD
-    private connectedClients: ReceiverProfile[] = []
-    private transportEventNotification: Subject<TransportEventNotification> = new Subject()
-    // this is assuming that the application will do request response, otherwise, just one will do.
-    private serverPort!: number
-    private serverUrl!: string
-
-    constructor(port?: number, url?: string) {
-        if (port) {
-           // instantiate the transport service. Eg: socket, http. Try to use the same service. Then return TransmitterConnectionAdapter
-            
-        }
-        /* For web browser ui, because this server can also act as a receiver, not just transmitter as well.  */
-        if (url) {
-            // if no transport service is instantiated, then instantiate a new one, otherwise use existying one.
-        }
-
-        if (!port && !url) console.error(`No role has assigned for transport service due to lack of information provided!`)
-        this.processOutputMessage()
-    }
-
-    subscribeConnectionState(): Observable<ConnectionState> {
-        throw new Error("Method not implemented.");
-    }
-    publishConnectionState(): void {
-        throw new Error("Method not implemented.");
-    }
-    connect(): void {
-        throw new Error("Method not implemented.");
-    }
-    disconnect(): void {
-        throw new Error("Method not implemented.");
-    }
-    send(message: any): Observable<any> {
-        return new Observable((response) => {
-            // logic here
-        })
-
-    }
-    emit(message: any): void {
-        // logic here
-    }
-    emitStream(message: any): void {
-        throw new Error("Method not implemented.");
-    }
-    subscribeMessages(messageFilter: any): Observable<any> {
-        throw new Error("Method not implemented.");
-    }
-    subscribe(subscriber: Subscriber<any>): Unsubscribable {
-        // Emit some value based on T (here for demonstration)
-        subscriber.next({} as any);
-        subscriber.complete();
-
-        // Return an Unsubscribable object to allow unsubscription
-        return {
-            unsubscribe: () => {
-                console.log('Unsubscribed');
-            }
-        };
-    }
-
-
-    public getTransportManagerEventNotification(): Observable<TransportManagerEventNotification> {
-        return new Observable((notification: Observer<TransportManagerEventNotification>) => {
-            this.transportEventNotification.subscribe((transportNotification: TransportEventNotification) => {
-                if (transportNotification.event == 'Connection') {
-                    notification.next({
-                        event: 'New Client Connection',
-                        data: transportNotification.data
-                    })
-                }
-            })
-        })
-    }
-
-    private async establishTransportTransmitting(tranportType: TransportType): Promise<ITransportTransmitting> {
-        console.log(`Setting up ${tranportType} transmitter`)
-        return new Promise((resolve, reject) => {
-            let setting: TransportSettings = {
-                profileInfo: {
-                    id: uuidv4(),
-                    name: 'For Server',
-                    port: this.serverPort,
-                    transport: tranportType
-                }
-            }
-            if (tranportType == 'WEBSOCKET') {
-                // logic here
-            } else {
-                reject(`No such Transport Type Exist...`)
-            }
-        })
-    }
-
-    private async establishTransportReceiving(tranportType: TransportType): Promise<ITransportReceiving> {
-        return new Promise((resolve, reject) => {
-            let setting: TransportSettings = {
-                profileInfo: {
-                    id: uuidv4(),
-                    name: 'For Client',
-                    url: this.serverUrl,
-                    transport: tranportType
-                }
-            }
-            // will be sharing one instance, This part may break the code
-            if (tranportType == 'WEBSOCKET') {
-                // logic here
-            }
-        })
-    }
-
-    // This function will wrap the message to be delivered over to established transport to be sent over
-    private processOutputMessage(): void {
-        this.outgoingMessageBus.subscribe({
-            next: (message: FisMessage) => {
-                if (message.header.messageName == 'NotificationMessage') {
-                    // This is just here temporarily. Because The application will be concerned with whom the party is subcribed to, not this transport manager
-                    // this.transmittingService.transmit({
-                    //     id: message.header.messageID,
-                    //     receiverID: '',
-                    //     payload: message,
-                    //     event: `notification`
-                    // })
-                }
-                if (message.header.messageName == 'ResponseMessage') {
-                    // Map responses according to the requestID???
-                    // this.transmittingService.transmit({
-                    //     id: message.header.messageID,
-                    //     receiverID: '',
-                    //     payload: message,
-                    //     event: `resposne`
-                    // })
-                }
-            }
-        })
-    }
-
-    // Responsibility include subscribing to event notification as well as tranpport instance for message transmission
-    private handleNewReceiver(receiver: ReceiverProfile) {
-        receiver.eventNotification.subscribe({
-            next: event => {
-                // new request will be handled. And then manager will here will pick it up from eventNotification and respond accordingly if there's a need for it
-                if (event.event == `Disconnection`) {
-                    console.error(`Client ${event.data?.receiverID ?? 'undefined'} disconnected.`)
-                    receiver.eventNotification.complete() // no need to listen since it's disconnected. A new one will be established when it reconnects again
-                }
-                if (event.event == `New Message`) {
-                    console.log(`New Client request ${event.data?.payload.header.messageID} at receiverID: ${receiver.uuid}`)
-                }
-            },
-            error: error => {
-                console.error(error)
-                receiver.eventNotification.error(error)
-            }
-        })
-    }
-}
-
-

+ 0 - 95
src/interface/ITransport.interface.ts

@@ -1,95 +0,0 @@
-import { Observable, Subject } from "rxjs";
-import { RetransmissionService } from "../utils/retransmission.service";
-
-export type TransportManagerEvent = 'New Client Connection' | 'New Client Request' | 'Client Disconnected'
-export type TransportEvent = 'Connection' | 'New Message' | 'Disconnection'
-export type TransportType = 'WEBSOCKET' | 'GRPC' | 'HTTP' | 'KAFKA' | undefined
-
-export interface TransportManagerInterface {
-    getTransportManagerEventNotification(): Observable<TransportManagerEventNotification>
-    // This is for acting as a transmitter
-    emit(message: TransportMessage): void
-    // For acting as a receiver to send a request. 
-    transmit(request: TransportMessage): Observable<TransportMessage>
-}
-export interface ITransport {
-    getTransportEventNotification(): Observable<TransportEventNotification>
-}
-
-export interface ITransportTransmitting extends ITransport {
-    transmit(message: TransportMessage): void
-}
-
-export interface ITransportReceiving extends ITransport {
-    // additional properties
-}
-
-export interface ITransportSuper extends ITransportTransmitting, ITransportReceiving {
-    // additional properties && methods  here
-}
-export interface TransportSettings {
-    profileInfo: ProfileInfo,
-}
-
-export interface ProfileInfo {
-    id: string,
-    name: string,
-    transport: TransportType,
-    url?: string | null,
-    port?: number | null
-}
-
-export interface TransmitterProfile {
-    uuid: string,
-    name: string,
-    dateCreated: Date,
-    transportType: TransportType,
-    eventNotification: Subject<TransportEventNotification>,
-    instance?: any
-}
-
-export interface ReceiverProfile {
-    uuid: string,
-    name: string,
-    dateCreated: Date,
-    transportType: TransportType,
-    eventNotification: Subject<TransportEventNotification>,
-    instance?: any
-}
-
-export interface ReceiverRetransmissionProfile extends ReceiverProfile {
-    buffer: RetransmissionService
-}
-
-export interface TransportEventNotification {
-    event: TransportEvent,
-    description: string,
-    transportType: TransportType,
-    data?: TransportPayload
-}
-
-export interface TransportManagerEventNotification {
-    event: TransportManagerEvent,
-    data?: TransportPayload
-}
-export interface TransportMessage {
-    id: string,
-    receiverID: string,
-    payload: any,
-    event: string
-}
-
-export interface TransportPayload {
-    receiverID: string,
-    receiverName: string,
-    date: Date,
-    payload?: any
-}
-
-
-export interface WrappedMessage {
-    timeReceived: any, // this property is for sender to sort
-    payload: any,
-    thisMessageID?: string,
-    previousMessageID?: string | null // this property is for receiver to sort
-}

+ 28 - 18
src/interface/connector.interface.ts

@@ -1,34 +1,26 @@
-import { Observable, Observer, PartialObserver, Subscribable, Subscriber, Unsubscribable } from "rxjs"
-import { FisAppActor } from "./transport.interface"
+import { Observable, Observer, PartialObserver, Subscribable, Subscriber, Subscription, Unsubscribable } from "rxjs"
+import { Bus, FisAppActor, ReceiverProfile, TransmisionMessage, TransmissionProfile, TransmitterProfile } from "./transport.interface"
 
 
 export type TYPE = {
     adapterProfile: AdapterProfile,
     transmitterProfile: TransmitterProfile,
-    receiverProfile: ReceiverProfile
+    receiverProfile: ReceiverProfile,
+    requestResponseProfile: TransmissionProfile
 }
 
 export interface AdapterProfile {
 
 }
 
-export interface TransmitterProfile {
-    id: string,
-    name: string,
-    dateCreated: Date
-}
-
-export interface ReceiverProfile {
-    id: string,
-    name: string,
-    dateCreated: Date
-}
 
 export interface ConnectionManager {
-
+    getTransmitterConnectionAdapter(): TransmitterConnectionAdapterBase
+    getReceiverConnectionAdapter(): ReceiverConnectionAdapterBase
+    getRequestResponseConnectionAdapter(): RequestResponseConnectionAdapter
 }
 
-export interface ConnectionAdaptorBase<T> extends FisAppActor, Subscribable<T> {
+export interface ConnectionAdaptorBase extends FisAppActor {
     connector: any
     connectorProfile: AdapterProfile | any
     connectionState: ConnectionState
@@ -43,14 +35,19 @@ export interface ConnectionAdaptorBase<T> extends FisAppActor, Subscribable<T> {
     emit(message: any): void
     emitStream(message: any): void
     subscribeMessages(messageFilter: any): Observable<any>
+    getMessageBus(bus: Bus): Observable<any>
 }
 
 
-export interface TransmitterConnectionAdapterBase<T> extends ConnectionAdaptorBase<T> {
+export interface TransmitterConnectionAdapterBase extends ConnectionAdaptorBase {
 
 }
 
-export interface ReceiverConnectionAdapterBase<T> extends ConnectionAdaptorBase<T> {
+export interface ReceiverConnectionAdapterBase extends ConnectionAdaptorBase {
+
+}
+
+export interface RequestResponseConnectionAdapter extends TransmitterConnectionAdapterBase, ReceiverConnectionAdapterBase {
 
 }
 
@@ -59,4 +56,17 @@ export enum AdaptorTransmissionRole {
     Transmitter,
     Receiver,
     RequestResponse
+}
+
+export enum Transport {
+    Websocket,
+    Grpc,
+    Http
+}
+export interface TransportMessage {
+    id: string,
+    dateCreated: Date,
+    transport: Transport,
+    adapter: string,
+    payload: TransmisionMessage
 }

+ 53 - 17
src/interface/transport.interface.ts

@@ -1,6 +1,24 @@
-import { Observable, Subject, Subscribable } from "rxjs";
-import { AdaptorTransmissionRole, ReceiverProfile, TransmitterProfile } from "./connector.interface";
+import { Observable, Subject } from "rxjs";
+import { AdaptorTransmissionRole, RequestResponseConnectionAdapter } from "./connector.interface";
+import { MessageTransmissionTransmitter } from "../transmission/msg.transmission.transmitter";
+import { MessageTransmissionReceiver } from "../transmission/msg.transmission.receiver";
+import { MessageTransmissionRequestResponse } from "../transmission/msg.transmission.request-response";
+import { ReceiverConnectionAdapter } from "../connector/connector.receiver";
+import { TransmitterConnectionAdapter } from "../connector/connector.transmitter";
 
+export interface MessageTransmissionManager {
+    // what the hell is this here for
+    getTransmissionInstance(): TransmissionProfile
+}
+
+export interface TransmissionProfile {
+    id: string,
+    receiverId: string,
+    transmitterId: string,
+    transmitter: MessageTransmissionTransmitter,
+    receiver: MessageTransmissionReceiver,
+    requestResponse: MessageRequestResponse
+}
 export interface FisAppActor {
     incomingMessageBus: Subject<any>
     outgoingMessageBus: Subject<any>
@@ -11,34 +29,33 @@ export interface FisAppActor {
     subscribeMessages(messageFilter: any): Observable<any>
 }
 
-export interface MessageTransmissionManager {
-    // what the hell is this here for
-}
-
-
-export interface MessageTransmissionBase<T> extends FisAppActor, Subscribable<T> {
-    transmitterProfile: TransmitterProfile
-    receiverProfile: ReceiverProfile
+export interface MessageTransmissionBase extends FisAppActor {
     msgRepositoryService: any
     transmissionRole: AdaptorTransmissionRole
     adaptorsArray: any[]
-    transmissionService: any
-    adapterService: any
+    transmissionService: any // not sure what this is for, i guess they are interchangeable with adapterService
+    adapterService: any // just use adapter Service, since it's grammatically closer to connectionadapter
 
-    setTransmitter(transmitterProfile: TransmitterProfile): void
-    setReceiver(receiverProfile: ReceiverProfile): void
+    getMessageBus(bus: Bus): Observable<any>
 }
 
-export interface MessageReceiver<T> extends MessageTransmissionBase<T> {
+export interface MessageReceiver extends MessageTransmissionBase {
+    receiverProfile: ReceiverProfile
 
+    setReceiver(receiverProfile: ReceiverProfile, role: AdaptorTransmissionRole, adapter: ReceiverConnectionAdapter): void
 }
 
-export interface MessageTransmitter<T> extends MessageTransmissionBase<T> {
+export interface MessageTransmitter extends MessageTransmissionBase {
+    transmitterProfile: TransmitterProfile
 
+    setTransmitter(transmitterProfile: TransmitterProfile, role: AdaptorTransmissionRole, adapter: TransmitterConnectionAdapter): void
 }
 
-export interface MessageRequestResponse<T> extends MessageTransmissionBase<T>, MessageReceiver<T> {
+export interface MessageRequestResponse extends MessageTransmissionBase {
+    transmitterInstance: MessageTransmissionTransmitter
+    receiverInstance: MessageTransmissionReceiver
 
+    setTransmissionProfile(transmissionInfo: MessageTransmissionTransmitter, receiverInfo: MessageTransmissionReceiver, role: AdaptorTransmissionRole, adapter: RequestResponseConnectionAdapter): void
 }
 
 export interface FisMessage {
@@ -49,8 +66,27 @@ export interface FisMessage {
     data: any
 }
 
+
+export interface TransmitterProfile {
+    id: string,
+    name: string,
+    dateCreated: Date
+}
+
+export interface ReceiverProfile {
+    id: string,
+    name: string,
+    dateCreated: Date,
+}
 export interface TransmisionMessage {
     transmitter?: TransmitterProfile,
     receiver?: ReceiverProfile,
     payload?: FisMessage
+}
+
+export enum Bus {
+    IncomingMessageBus,
+    OutgoingMessageBus,
+    ErrorMessageBus,
+    NotificationMessageBus
 }

+ 10 - 9
src/test/transmitter.ts

@@ -1,19 +1,20 @@
 import { Observable, Subject } from "rxjs";
-import { FisAppActor, FisMessage } from "../interface/transport.interface";
+import { FisAppActor, FisMessage, TransmissionProfile } from "../interface/transport.interface";
 import { MessageTransmissionBase } from "../transmission/msg.transmission.base";
 import dotenv from 'dotenv';
+import { MessageTransmissionManager } from "../transmission/msg.transmission.manager";
 
 /*  These are the purple fonts. Gonna interact with blue fonts to set up the credentials to establish the necessary roles.
 Assuming the primary role is server. That means we will need transmitter and multiple receiver profiles that are connected. */
 class Application implements FisAppActor {
-    incomingMessageBus!: Subject<FisMessage>
-    outgoingMessageBus!: Subject<FisMessage>
-    transmissionService!: MessageTransmissionBase
+    incomingMessageBus: Subject<FisMessage> = new Subject()
+    outgoingMessageBus: Subject<FisMessage> = new Subject()
+    messageTransmissionManager: MessageTransmissionManager
+    transmissionInstance!: TransmissionProfile
 
-    constructor(messageTransmissionBase: MessageTransmissionBase) {
-        this.transmissionService = messageTransmissionBase
-        this.incomingMessageBus = messageTransmissionBase.incomingMessageBus
-        this.outgoingMessageBus = messageTransmissionBase.outgoingMessageBus
+    constructor() {
+        this.messageTransmissionManager = new MessageTransmissionManager()
+        this.transmissionInstance = this.messageTransmissionManager.getTransmissionInstance()
     }
 
     send(message: FisMessage): Observable<FisMessage> {
@@ -46,4 +47,4 @@ class Application implements FisAppActor {
     }
 }
 
-const application = new Application(new MessageTransmissionBase())
+const application = new Application()

+ 0 - 39
src/transmission/msg.receiver.ts

@@ -1,39 +0,0 @@
-import { Subject, Subscriber, Unsubscribable } from 'rxjs';
-import { AdaptorTransmissionRole, TransmitterProfile } from '../interface/connector.interface';
-import { MessageTransmissionBase } from './msg.transmission.base';
-import { MessageReceiver as MessageReceiverInterface } from '../interface/transport.interface'
-import { ConnectionAdapter } from '../connector/connector';
-
-export class MessageReceiver extends MessageTransmissionBase implements MessageReceiverInterface<any> {
-    receiverProfile: TransmitterProfile; // Property to hold the receiver profile
-    transmissionRole: AdaptorTransmissionRole;
-    incomingMessageBus: Subject<any> = new Subject()
-
-    constructor(receiverProfile: TransmitterProfile) {
-        super();
-        this.transmissionRole = AdaptorTransmissionRole.Receiver;
-        this.receiverProfile = receiverProfile;
-        this.instantiateConnectionAdapter()
-    }
-
-    // Implement Subscribable's subscribe method. All messages pass through here
-    subscribe(subscriber: Subscriber<any>): Unsubscribable {
-        // Emit some value based on T (here for demonstration)
-        subscriber.next({} as any);
-        subscriber.complete();
-
-        // Return an Unsubscribable object to allow unsubscription
-        return {
-            unsubscribe: () => {
-                console.log('Unsubscribed');
-            }
-        };
-    }
-
-    private instantiateConnectionAdapter(): void {
-        this.adapterService = new ConnectionAdapter()
-        this.adapterService.subscribe((message: any) => {
-            this.incomingMessageBus.next(message)
-        })
-    }
-}

+ 11 - 29
src/transmission/msg.transmission.base.ts

@@ -1,13 +1,10 @@
 
-import { Observable, Observer, Subject, Unsubscribable } from 'rxjs';
-import { TransmitterProfile, ReceiverProfile, AdaptorTransmissionRole } from '../interface/connector.interface';
-import { MessageTransmissionBase as MessageTransmissionBaseInterface } from '../interface/transport.interface'
+import { filter, Observable, Observer, Subject, Subscription, takeWhile, Unsubscribable } from 'rxjs';
+import { AdaptorTransmissionRole } from '../interface/connector.interface';
+import { Bus, FisMessage, MessageTransmissionBase as MessageTransmissionBaseInterface } from '../interface/transport.interface'
 import { v4 as uuidv4 } from 'uuid'
-import { MessageTransmitter } from './msg.transmitter';
 
-export class MessageTransmissionBase implements MessageTransmissionBaseInterface<any> {
-    transmitterProfile!: TransmitterProfile;
-    receiverProfile!: ReceiverProfile;
+export class MessageTransmissionBase implements MessageTransmissionBaseInterface {
     msgRepositoryService: any;
     transmissionRole!: AdaptorTransmissionRole;
     adaptorsArray!: any[];
@@ -17,34 +14,19 @@ export class MessageTransmissionBase implements MessageTransmissionBaseInterface
     outgoingMessageBus!: Subject<any>;
 
     constructor() {
-        // these are for self. Not to be confused with setting up credentials for connected clients in the context of websocket
-        this.setTransmitter({
-            id: uuidv4(),
-            name: 'Transmitter' + process.env.PORT,
-            dateCreated: new Date()
-        })
-        this.setReceiver({
-            id: uuidv4(),
-            name: 'Receiver',
-            dateCreated: new Date()
-        })
-    }
-    
-    subscribe(observer: Partial<Observer<any>>): Unsubscribable {
-        throw new Error('Method not implemented.');
+        // logic here
     }
 
-    // Pretty straight forward. Set itself straight away.
-    setTransmitter(transmitterProfile: TransmitterProfile): MessageTransmitter {
-        return new MessageTransmitter(transmitterProfile)
+    getMessageBus(bus: Bus): Observable<any> {
+        throw new Error('Method not implemented.');
     }
 
-    setReceiver(receiverProfile: ReceiverProfile): void {
-        this.receiverProfile = receiverProfile
+    send(message: any): Observable<any> {
+        throw new Error(`Method not implemented.`)
     }
 
-    send(message: any): Observable<any> {
-       throw new Error(`Method not implemented`)
+    subscribe(observer: Partial<Observer<any>>): Unsubscribable {
+        throw new Error('Method not implemented.');
     }
     emit(message: any): void {
         throw new Error('Method not implemented.');

+ 53 - 2
src/transmission/msg.transmission.manager.ts

@@ -1,6 +1,57 @@
+import { MessageTransmissionTransmitter } from "./msg.transmission.transmitter";
+import { MessageTransmissionReceiver } from "./msg.transmission.receiver";
+import { ConnectionManager } from "../connector/connector.manager";
+import { MessageTransmissionManager as MessageTransmissionManagerInterface, ReceiverProfile, TransmissionProfile, TransmitterProfile } from "../interface/transport.interface";
+import { v4 as uuidv4 } from 'uuid'
+import { AdaptorTransmissionRole } from "../interface/connector.interface";
+import { MessageTransmissionRequestResponse } from "./msg.transmission.request-response";
+/* FOr now, to fill the holes/gaps so to speak, the FIS actor will interact wtih Message Transmission Manager, without having to wory about
+the underyling transport protocol as well as managing client control, when it's acting as a transmitter. */
+export class MessageTransmissionManager implements MessageTransmissionManagerInterface {
+    transmission: TransmissionProfile[] = []
+    connectionManager!: ConnectionManager
 
+    constructor() {
+        // logic here
+    }
 
+    // but this function also needs to talk to connection adaptor manager to instantiate the necessary adapter.
+    getTransmissionInstance(): TransmissionProfile {
+        let transmitter = this.getTransmitter()
+        let receiver = this.getReceiver()
+        let transmission: TransmissionProfile = {
+            id: uuidv4(),
+            receiverId: uuidv4(),
+            transmitterId: uuidv4(),
+            transmitter: transmitter,
+            receiver: receiver,
+            requestResponse: new MessageTransmissionRequestResponse(transmitter, receiver, AdaptorTransmissionRole.RequestResponse, this.connectionManager.getRequestResponseConnectionAdapter())
+        }
+        this.instantiateConnectionManager(transmission) // start an adapter
+        this.transmission.push(transmission)
+        return transmission
+    }
+
+    private getTransmitter(): MessageTransmissionTransmitter {
+        let transmitterProfile: TransmitterProfile = {
+            id: uuidv4(),
+            name: '', // for now make it empty. We will use the assigned uuid here
+            dateCreated: new Date()
+        }
+        return new MessageTransmissionTransmitter(transmitterProfile, AdaptorTransmissionRole.Transmitter, this.connectionManager.getTransmitterConnectionAdapter())
+    }
+
+    private getReceiver(): MessageTransmissionReceiver {
+        let receiverProfile: ReceiverProfile = {
+            id: uuidv4(),
+            name: '', // for now make it empty. We will use the assigned uuid here
+            dateCreated: new Date()
+        }
+        return new MessageTransmissionReceiver(receiverProfile, AdaptorTransmissionRole.Receiver, this.connectionManager.getReceiverConnectionAdapter())
+    }
+
+    private instantiateConnectionManager(transmissionProfile: TransmissionProfile): void {
+        this.connectionManager = new ConnectionManager(transmissionProfile)
+    }
 
-export class MessageTransmissionManager {
-    
 }

+ 26 - 0
src/transmission/msg.transmission.receiver.ts

@@ -0,0 +1,26 @@
+import { PartialObserver, Subject, Subscriber, Unsubscribable } from 'rxjs';
+import { AdaptorTransmissionRole } from '../interface/connector.interface';
+import { MessageTransmissionBase } from './msg.transmission.base';
+import { MessageReceiver as MessageReceiverInterface, ReceiverProfile, TransmitterProfile } from '../interface/transport.interface'
+import { ConnectionAdapter } from '../connector/connector.base';
+import { v4 as uuidv4 } from 'uuid'
+import { ReceiverConnectionAdapter } from '../connector/connector.receiver';
+
+export class MessageTransmissionReceiver extends MessageTransmissionBase implements MessageReceiverInterface {
+    receiverProfile!: ReceiverProfile;
+
+    constructor(profile: ReceiverProfile, role: AdaptorTransmissionRole, adapter: ReceiverConnectionAdapter) {
+        super();
+        this.setReceiver(profile, role, adapter)
+    }
+
+    setReceiver(receiverProfile: ReceiverProfile, role: AdaptorTransmissionRole, adapter: ReceiverConnectionAdapter): void {
+        this.receiverProfile = receiverProfile
+        this.transmissionRole = role
+        this.adapterService = adapter
+    }
+
+    private instantiateConnectionAdapter(): void {
+        // logic here
+    }
+}

+ 52 - 0
src/transmission/msg.transmission.request-response.ts

@@ -0,0 +1,52 @@
+import { MessageTransmissionBase } from "./msg.transmission.base";
+import { FisMessage, MessageReceiver, MessageRequestResponse as MessageRequestResponseInterface } from '../interface/transport.interface'
+import { filter, Observable, Observer, Subscription, takeWhile } from "rxjs";
+import { v4 as uuidv4 } from 'uuid'
+import { AdaptorTransmissionRole, RequestResponseConnectionAdapter } from "../interface/connector.interface";
+import { MessageTransmissionReceiver } from "./msg.transmission.receiver";
+import { MessageTransmissionTransmitter } from "./msg.transmission.transmitter";
+
+export class MessageTransmissionRequestResponse extends MessageTransmissionBase implements MessageRequestResponseInterface {
+    transmitterInstance!: MessageTransmissionTransmitter;
+    receiverInstance!: MessageTransmissionReceiver;
+
+    constructor(transmitterInstance: MessageTransmissionTransmitter, receiverInstance: MessageTransmissionReceiver, role: AdaptorTransmissionRole, adapter: RequestResponseConnectionAdapter) {
+        super()
+        this.setTransmissionProfile(transmitterInstance, receiverInstance, role, adapter)
+    }
+
+    setTransmissionProfile(transmitterInstance: MessageTransmissionTransmitter, receiverInstance: MessageTransmissionReceiver, role: AdaptorTransmissionRole, adapter: RequestResponseConnectionAdapter): void {
+        this.transmitterInstance = transmitterInstance
+        this.receiverInstance = receiverInstance
+        this.transmissionRole = role
+        this.adapterService = adapter
+    }
+
+    // To be Enhanced. This is actually wrong at the moment
+    send(message: FisMessage): Observable<FisMessage> {
+        return new Observable((response: Observer<FisMessage>) => {
+            this.transmitterInstance.send({
+                transmitter: '',
+                payload: message
+            });
+
+            const subscription: Subscription = this.incomingMessageBus
+                .pipe(
+                    // Filter for matching message IDs
+                    filter(incomingMessage => incomingMessage.header.messageID === message.header.messageID),
+                    // Complete the observable when the data is 'Complete'
+                    takeWhile(incomingMessage => incomingMessage.data !== 'Complete')
+                )
+                .subscribe({
+                    next: incomingMessage => {
+                        response.next(incomingMessage);
+                        // Complete the observable if data is 'Complete'
+                        if (incomingMessage.data === 'Complete') {
+                            response.complete();
+                            subscription.unsubscribe();
+                        }
+                    }
+                });
+        });
+    }
+}

+ 28 - 0
src/transmission/msg.transmission.transmitter.ts

@@ -0,0 +1,28 @@
+import { MessageTransmissionBase } from "./msg.transmission.base";
+import { FisMessage,  MessageTransmitter as MessageTransmitterInterface, TransmitterProfile } from '../interface/transport.interface'
+import { AdaptorTransmissionRole } from "../interface/connector.interface";
+import { v4 as uuidv4 } from 'uuid'
+import { TransmitterConnectionAdapter } from "../connector/connector.transmitter";
+
+export class MessageTransmissionTransmitter extends MessageTransmissionBase implements MessageTransmitterInterface {
+    transmitterProfile!: TransmitterProfile;
+
+    constructor(profile: TransmitterProfile, role: AdaptorTransmissionRole, adapter: TransmitterConnectionAdapter) {
+        super()
+        this.setTransmitter(profile, role, adapter)
+    }
+    
+    setTransmitter(transmitterProfile: TransmitterProfile, role: AdaptorTransmissionRole, adapter: TransmitterConnectionAdapter): void {
+        this.transmitterProfile = transmitterProfile
+        this.transmissionRole = role
+        this.adapterService = adapter
+    }
+
+    emit(message: FisMessage): void {
+        throw new Error(`Method not implemented`)
+    }
+
+    getTransmitterInfo(): TransmitterProfile {
+        return this.transmitterProfile
+    }
+}

+ 0 - 48
src/transmission/msg.transmitter.ts

@@ -1,48 +0,0 @@
-import { MessageTransmissionBase } from "./msg.transmission.base";
-import { FisMessage, MessageTransmitter as MessageTransmitterInterface } from '../interface/transport.interface'
-import { AdaptorTransmissionRole, TransmitterProfile } from "../interface/connector.interface";
-import { filter, Observable, Observer, Subscription, takeWhile } from "rxjs";
-
-export class MessageTransmitter extends MessageTransmissionBase implements MessageTransmitterInterface<any> {
-
-    constructor(transmitterProfile: TransmitterProfile) {
-        super()
-        this.transmissionRole = AdaptorTransmissionRole.Transmitter
-        this.transmitterProfile = transmitterProfile
-    }
-
-    send(message: FisMessage): Observable<FisMessage> {
-        return new Observable((response: Observer<FisMessage>) => {
-            this.transmissionService.send({
-                transmitter: this.transmitterProfile,
-                payload: message
-            });
-    
-            const subscription: Subscription = this.incomingMessageBus
-                .pipe(
-                    // Filter for matching message IDs
-                    filter(incomingMessage => incomingMessage.header.messageID === message.header.messageID),
-                    // Complete the observable when the data is 'Complete'
-                    takeWhile(incomingMessage => incomingMessage.data !== 'Complete')
-                )
-                .subscribe({
-                    next: incomingMessage => {
-                        response.next(incomingMessage);
-                        // Complete the observable if data is 'Complete'
-                        if (incomingMessage.data === 'Complete') {
-                            response.complete();
-                            subscription.unsubscribe();
-                        }
-                    }
-                });
-        });
-    }
-
-    emit(message: any): void {
-        // emit base on receiver
-    }
-
-    emitStream(message: any): void {
-
-    }
-}