Parcourir la source

soem strucural adjustments

Dr-Swopt il y a 1 mois
Parent
commit
5d0497e3b2

+ 2 - 2
.env

@@ -1,5 +1,5 @@
 ;Transport = "Websocket, Http"
 ;PORT = 3000, 3001
-# Transport = "Websocket"
-Transport = "Http"
+Transport = "Websocket"
+# Transport = "Http"
 PORT = 3000

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

@@ -8,7 +8,7 @@ import { WebsocketTransportService } from "../transport/websocket"
 import { HttpTransportService } from "../transport/http"
 import config from '../config/config.json';
 
-console.log(config);export class ConnectionManager implements ConnectionManagerInterface {
+export class ConnectionManager implements ConnectionManagerInterface {
     private transportServiceArray: TransportService[] = []
     private transportSet: Set<TransportSet> = new Set()
     private adapterSet: AdapterSet[] = []
@@ -24,26 +24,34 @@ console.log(config);export class ConnectionManager implements ConnectionManagerI
         })
     }
 
-    getAdapter(clientId: string, transportService: TransportService): AdapterSet {
-        let transportType: Transport = transportService.getInfo()
-        let adapterId: string = clientId
-        let transmitterAdapter: TransmitterConnectionAdapter = new TransmitterConnectionAdapter(adapterId, transportType, transportService)
-        let receiverAdapter: ReceiverConnectionAdapter = new ReceiverConnectionAdapter(adapterId, transportType, transportService)
-        let adapterSet: AdapterSet = {
-            id: adapterId,
-            dateCreated: new Date(),
-            transmitterAdapter: transmitterAdapter,
-            receiverAdapter: receiverAdapter,
-            requestResponsAdapter: new RequestResponseConnectionAdapter(transmitterAdapter, receiverAdapter)
-        }
-        this.adapterSet.push(adapterSet)
+    async getAdapter(clientId: string): Promise<AdapterSet> {
+        return new Promise((resolve, reject) => {
+            console.log(`Instantiating an adapter set....`)
+            let transportType: Transport = Transport.Websocket // as default  for now
+            let adapterId: string = clientId
+            let transportService: TransportService | undefined = this.transportServiceArray.find(obj => obj.getInfo() == transportType)
+            if (transportService) {
+                let transmitterAdapter: TransmitterConnectionAdapter = new TransmitterConnectionAdapter(adapterId, transportType, transportService)
+                let receiverAdapter: ReceiverConnectionAdapter = new ReceiverConnectionAdapter(adapterId, transportType, transportService)
+                let adapterSet: AdapterSet = {
+                    id: adapterId,
+                    dateCreated: new Date(),
+                    transmitterAdapter: transmitterAdapter,
+                    receiverAdapter: receiverAdapter,
+                    requestResponsAdapter: new RequestResponseConnectionAdapter(transmitterAdapter, receiverAdapter)
+                }
+                this.adapterSet.push(adapterSet)
 
-        this.event.next({
-            id: uuidv4(),
-            event: 'New Adapter',
-            data: adapterId
-        } as TransportEvent)
-        return adapterSet
+                this.event.next({
+                    id: uuidv4(),
+                    event: 'New Adapter',
+                    data: adapterId
+                } as TransportEvent)
+                resolve(adapterSet)
+            } else {
+                reject(`Connection Manager: No Transport Service Instantiated!`)
+            }
+        })
     }
 
     public getTransportArray(): TransportService[] {
@@ -57,16 +65,16 @@ console.log(config);export class ConnectionManager implements ConnectionManagerI
             this.transportServiceArray.push(transportService)
             if (transportService instanceof WebsocketTransportService) {
                 console.log(`Just Double Checking... this is websocket`)
-                if(isClient) {
+                if (isClient) {
                     // please note this is subject to change depending on the UI environemnt. Angular has their own built in function to read json file based on Swopt-UI
-                    transportService.startClient(config.connection.transmitter) 
+                    transportService.startClient(config.connection.transmitter)
                 } else {
                     transportService.startServer(transportSet.port);
                 }
             } else if (transportService instanceof HttpTransportService) {
                 console.log(`Just Double Checking... this is http`)
                 // Additional Http-specific setup if needed.
-                if(isClient) {
+                if (isClient) {
                     transportService.startClient(`http://localhost:3000`)
                 } else {
                     transportService.startServer(transportSet.port)
@@ -94,6 +102,7 @@ console.log(config);export class ConnectionManager implements ConnectionManagerI
         transportList.forEach((transport, index) => {
             transportSet.add({ transport: transport, port: portList[index] } as unknown as TransportSet)
         })
+        console.log(this.transportSet)
     }
 
 }

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

@@ -9,9 +9,9 @@ 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 ReceiverConnectionAdapterInterface {
-    constructor(adapterId: string, transportType: Transport, adapter: TransportService) {
+    constructor(adapterId: string, transportType: Transport, transportService: TransportService) {
         super()
-        this.connector = adapter
+        this.connector = transportService
         this.setAdapterProfile(adapterId, transportType)
     }
 
@@ -23,6 +23,7 @@ export class ReceiverConnectionAdapter extends ConnectionAdapter implements Rece
     }
 
     getMessageBus(bus: Bus): Observable<TransportEvent> {
+        console.log(`Connector getting message bus`)
         return new Observable((observable: Observer<TransportEvent>) => {
             if (bus == Bus.GeneralBus) {
                 const subscription: Subscription = this.connector.subscribe().pipe(

+ 1 - 1
src/interface/connector.interface.ts

@@ -17,7 +17,7 @@ export interface AdapterProfile {
 
 
 export interface ConnectionManager {
-    getAdapter(clientId: string, transportService: TransportService): AdapterSet
+    getAdapter(clientId: string, transportService: TransportService): Promise<AdapterSet>
 }
 
 export interface ConnectionAdaptorBase {

+ 3 - 3
src/interface/transport.interface.ts

@@ -1,5 +1,5 @@
 import { Observable, Subject } from "rxjs";
-import { AdapterProfile, AdapterSet, AdaptorTransmissionRole, ConnectionManager, RequestResponseConnectionAdapter, TransportEvent, TransportService } from "./connector.interface";
+import { AdapterProfile, AdapterSet, AdaptorTransmissionRole, ConnectionAdaptorBase, ConnectionManager, RequestResponseConnectionAdapter, TransportEvent, TransportService } from "./connector.interface";
 import { MessageTransmissionTransmitter } from "../transmission/msg.transmission.transmitter";
 import { MessageTransmissionReceiver } from "../transmission/msg.transmission.receiver";
 import { ConnectionAdapter } from "../connector/connector.base";
@@ -20,10 +20,10 @@ export interface MessageTransmission {
 export interface MessageTransmissionBase {
     msgRepositoryService: any // like logging service and what not
     transmissionRole: AdaptorTransmissionRole
-    adaptorsArray: Array<ConnectionAdapter>
+    mainAdapter: ConnectionAdapter
 
     getInfo(): TransmissionProfile
-    setUpAdapter(adapterSet: AdapterSet[]): void
+    setUpAdapter(adapter: ConnectionAdapter): void
 }
 
 export interface MessageReceiver extends MessageTransmissionBase {

+ 2 - 2
src/transmission/msg.transmission.base.ts

@@ -11,7 +11,7 @@ export class MessageTransmissionBase implements MessageTransmissionBaseInterface
     transmissionRole!: AdaptorTransmissionRole;
     adaptorsArray: Array<ConnectionAdapter> = []
     transmissionService: any;
-    adapterService!: ConnectionAdapter | undefined
+    mainAdapter!: ConnectionAdapter;
 
     constructor(event: Observable<TransportEvent>) {
         // logic here
@@ -21,7 +21,7 @@ export class MessageTransmissionBase implements MessageTransmissionBaseInterface
         throw new Error(`Method not implemented`)
     }
 
-    setUpAdapter(adapterSet: AdapterSet[]): void {
+    setUpAdapter(adapter: ConnectionAdapter): void {
         throw new Error(`Method not implemented`)
     }
 

+ 40 - 31
src/transmission/msg.transmission.manager.ts

@@ -6,6 +6,9 @@ import { v4 as uuidv4 } from 'uuid'
 import { AdapterSet, TransportEvent, Event } from "../interface/connector.interface";
 import { MessageTransmissionRequestResponse } from "./msg.transmission.request-response";
 import { filter, Observable, Observer, Subject } from "rxjs";
+import { error } from "console";
+import { TransmitterConnectionAdapter } from "../connector/connector.transmitter";
+import { ReceiverConnectionAdapter } from "../connector/connector.receiver";
 
 export class MessageTransmissionManager implements MessageTransmissionManagerInterface {
     private browserEnv!: boolean
@@ -36,54 +39,57 @@ export class MessageTransmissionManager implements MessageTransmissionManagerInt
                 filter(event => event.event == targetEvent)
             ).subscribe(event => {
                 // get all adapters for all the connection
-                observer.next(this.instantiateComponents((event.data as EventMessage).clientId))
+                this.instantiateComponents((event.data as EventMessage).clientId).then((messageTransmission: MessageTransmission) => {
+                    observer.next(messageTransmission)
+                }).catch(error => {
+                    console.error(error)
+                })
             })
         })
     }
 
-    private instantiateComponents(clientId: string): MessageTransmission {
-        console.log(`Instantiating new transmission set for another ${this.browserEnv ? 'Server' : 'Client'}`)
-        let adapterSet: AdapterSet[] = []
-        if (this.connectionManager.getTransportArray().length > 0) {
-            this.connectionManager.getTransportArray().forEach(transport => {
-                adapterSet.push(this.connectionManager.getAdapter(clientId, transport))
-            })
-        } else {
-            throw new Error(`Transmission Manager: No transport is Instantiated`)
-        }
-
-        // 1 set only
-        let transmitter: MessageTransmissionTransmitter = this.getTransmitter(clientId, adapterSet, this.event.asObservable())
-        let receiver: MessageTransmissionReceiver = this.getReceiver(clientId, adapterSet, this.event.asObservable())
-        let requestResponse: MessageTransmissionRequestResponse = this.getRequestResponse(transmitter, receiver, this.event.asObservable())
-        let transmission: MessageTransmission = {
-            id: clientId,
-            transmitter: transmitter,
-            receiver: receiver,
-            requestResponse: requestResponse,
-            event: this.event.asObservable()
-        }
-        this.transmission.push(transmission)
-        return transmission
+    private async instantiateComponents(clientId: string): Promise<MessageTransmission> {
+        return new Promise(async (resolve, reject) => {
+            console.log(`Instantiating new transmission set for another ${this.browserEnv ? 'Server' : 'Client'}`)
+            if (this.connectionManager.getTransportArray().length > 0) {
+                await this.connectionManager.getAdapter(clientId).then((adapterSet: AdapterSet) => {
+                    // 1 set only
+                    let transmitter: MessageTransmissionTransmitter = this.getTransmitter(clientId, adapterSet.transmitterAdapter, this.event.asObservable())
+                    let receiver: MessageTransmissionReceiver = this.getReceiver(clientId, adapterSet.receiverAdapter, this.event.asObservable())
+                    let requestResponse: MessageTransmissionRequestResponse = this.getRequestResponse(transmitter, receiver, this.event.asObservable())
+                    let transmission: MessageTransmission = {
+                        id: clientId,
+                        transmitter: transmitter,
+                        receiver: receiver,
+                        requestResponse: requestResponse,
+                        event: this.event.asObservable()
+                    }
+                    this.transmission.push(transmission)
+                    resolve(transmission)
+                }).catch((error) => console.error(error))
+            } else {
+                reject(`Transmission Manager: No transport is Instantiated`)
+            }
+        })
     }
 
 
-    private getTransmitter(transmissionId: string, adapterSets: AdapterSet[], event: Observable<TransportEvent>): MessageTransmissionTransmitter {
+    private getTransmitter(transmissionId: string, adapter: TransmitterConnectionAdapter, event: Observable<TransportEvent>): MessageTransmissionTransmitter {
         let transmitterProfile: TransmitterProfile = {
             id: transmissionId,
             name: '', // for now make it empty. We will use the assigned uuid here
             dateCreated: new Date()
         }
-        return new MessageTransmissionTransmitter(transmitterProfile, adapterSets, event)
+        return new MessageTransmissionTransmitter(transmitterProfile, adapter, event)
     }
 
-    private getReceiver(transmissionId: string, adapterSets: AdapterSet[], event: Observable<TransportEvent>): MessageTransmissionReceiver {
+    private getReceiver(transmissionId: string, adapter: ReceiverConnectionAdapter, event: Observable<TransportEvent>): MessageTransmissionReceiver {
         let receiverProfile: ReceiverProfile = {
             id: transmissionId,
             name: '', // for now make it empty. We will use the assigned uuid here
             dateCreated: new Date()
         }
-        return new MessageTransmissionReceiver(receiverProfile, adapterSets, event)
+        return new MessageTransmissionReceiver(receiverProfile, adapter, event)
     }
 
     private getRequestResponse(transmitterInstance: MessageTransmissionTransmitter, receiverInstance: MessageTransmissionReceiver, event: Observable<TransportEvent>): MessageTransmissionRequestResponse {
@@ -108,8 +114,11 @@ export class MessageTransmissionManager implements MessageTransmissionManagerInt
     private reconnectionHandler(clientId: string): void {
         let transmissionObj: MessageTransmission | undefined = Array.from(this.transmission).find(obj => obj.id === clientId)
         if (!transmissionObj) {
-            let transmission: MessageTransmission = this.instantiateComponents(clientId)
-            this.transmission.push(transmission)
+            this.instantiateComponents(clientId).then((messageTransmission: MessageTransmission) => {
+                this.transmission.push(messageTransmission)
+            }).catch((error) => {
+                console.error(error)
+            })
         }
     }
 

+ 8 - 11
src/transmission/msg.transmission.receiver.ts

@@ -5,17 +5,19 @@ import { Bus, EventMessage, MessageReceiver as MessageReceiverInterface, Receive
 import { v4 as uuidv4 } from 'uuid'
 import { ReceiverConnectionAdapter } from '../connector/connector.receiver';
 import { checkMessage, WrappedMessage } from '../utils/message.ordering';
+import { TransmitterConnectionAdapter } from '../connector/connector.transmitter';
+import { ConnectionAdapter } from '../connector/connector.base';
 
 export class MessageTransmissionReceiver extends MessageTransmissionBase implements MessageReceiverInterface {
     private onHoldMessage: Subject<WrappedMessage> = new Subject()
     // private toBePassedOver: Subject<WrappedMessage> = new Subject()
     receiverProfile!: ReceiverProfile;
 
-    constructor(profile: ReceiverProfile, adapterSets: AdapterSet[], event: Observable<TransportEvent>) {
+    constructor(profile: ReceiverProfile, adapter: ReceiverConnectionAdapter, event: Observable<TransportEvent>) {
         super(event);
 
         this.setReceiver(profile)
-        this.setUpAdapter(adapterSets)
+        this.setUpAdapter(adapter)
     }
 
     setReceiver(receiverProfile: ReceiverProfile): void {
@@ -23,12 +25,13 @@ export class MessageTransmissionReceiver extends MessageTransmissionBase impleme
     }
 
     getMessageBus(bus: Bus): Observable<TransportEvent> {
+        console.log(`Transmission getting message bus`)
         return new Observable((observable: Observer<TransportEvent>) => {
             // logic here
             if (bus == Bus.GeneralBus) {
                 // Need to merge all the adapters into one when the time comes 
                 // SAMPLE: This adapterArray.forEach(adapter => { ... })
-                const subscription: Subscription = (this.adapterService as ReceiverConnectionAdapter).getMessageBus(Bus.GeneralBus).pipe(
+                const subscription: Subscription = (this.mainAdapter as ReceiverConnectionAdapter).getMessageBus(Bus.GeneralBus).pipe( 
                     filter((event: TransportEvent) => event.event == 'New Message'),
                 ).subscribe((event: TransportEvent) => {
                     // console.log(event) // data is transportMessage instead of eventmessage
@@ -48,13 +51,7 @@ export class MessageTransmissionReceiver extends MessageTransmissionBase impleme
         })
     }
 
-    setUpAdapter(adapterSets: AdapterSet[]): void {
-        if (adapterSets.length > 0) {
-            adapterSets.forEach((adapter: AdapterSet) => {
-                this.adaptorsArray.push(adapter.receiverAdapter)
-            })
-        }
-        // for now just hardcode to use 1 adapter type until connection manager is further enhacne to configure adapters on the fly
-        this.adapterService = this.adaptorsArray.find(obj => obj.getInfo().transportType === Transport.Websocket)
+    setUpAdapter(adapter: ConnectionAdapter): void {
+        this.mainAdapter = adapter
     }
 }

+ 4 - 9
src/transmission/msg.transmission.request-response.ts

@@ -2,9 +2,10 @@ import { MessageTransmissionBase } from "./msg.transmission.base";
 import { FisMessage, MessageRequestResponse as MessageRequestResponseInterface } from '../interface/transport.interface'
 import { filter, Observable, Observer, Subject, Subscription, takeWhile } from "rxjs";
 import { v4 as uuidv4 } from 'uuid'
-import { AdapterSet, Transport, TransportEvent } from "../interface/connector.interface";
+import { TransportEvent } from "../interface/connector.interface";
 import { MessageTransmissionReceiver } from "./msg.transmission.receiver";
 import { MessageTransmissionTransmitter } from "./msg.transmission.transmitter";
+import { ConnectionAdapter } from "../connector/connector.base";
 
 export class MessageTransmissionRequestResponse extends MessageTransmissionBase implements MessageRequestResponseInterface {
     transmitterInstance!: MessageTransmissionTransmitter;
@@ -47,13 +48,7 @@ export class MessageTransmissionRequestResponse extends MessageTransmissionBase
         });
     }
 
-    setUpAdapter(adapterSets: AdapterSet[]): void {
-        if (adapterSets.length > 0) {
-            adapterSets.forEach((adapter: AdapterSet) => {
-                this.adaptorsArray.push(adapter.requestResponsAdapter)
-            })
-        }
-        // for now just hardcode to use 1 adapter type until connection manager is further enhacne to configure adapters on the fly
-        this.adapterService = this.adaptorsArray.find(obj => obj.getInfo().transportType === Transport.Websocket)
+    setUpAdapter(adapter: ConnectionAdapter): void {
+        this.mainAdapter = adapter
     }
 }

+ 7 - 11
src/transmission/msg.transmission.transmitter.ts

@@ -1,11 +1,12 @@
 import { MessageTransmissionBase } from "./msg.transmission.base";
 import { EventMessage, FisMessage, MessageTransmitter as MessageTransmitterInterface, TransmitterProfile } from '../interface/transport.interface'
-import { AdapterSet, ConnectionState, Event, Transport, TransportEvent, TransportMessage } from "../interface/connector.interface";
+import { AdapterSet, ConnectionAdaptorBase, ConnectionState, Event, Transport, TransportEvent, TransportMessage } from "../interface/connector.interface";
 import { v4 as uuidv4 } from 'uuid'
 import { TransmitterConnectionAdapter } from "../connector/connector.transmitter";
 import { BehaviorSubject, filter, map, Observable, Subject } from "rxjs";
 import { RetransmissionService } from "../utils/retransmission.service";
 import { WrappedMessage } from "../utils/message.ordering";
+import { ConnectionAdapter } from "../connector/connector.base";
 
 /* Take in all the messages that needs to be transported, and divide them accordingly. So the connector instances will do just that
 connectors or adapters will have their own identifier*/
@@ -14,13 +15,13 @@ export class MessageTransmissionTransmitter extends MessageTransmissionBase impl
     transmitterProfile!: TransmitterProfile;
     retransmission!: RetransmissionService;
 
-    constructor(profile: TransmitterProfile, adapterSets: AdapterSet[], event: Observable<TransportEvent>) {
+    constructor(profile: TransmitterProfile, adapter: TransmitterConnectionAdapter, event: Observable<TransportEvent>) {
         super(event)
         this.event = event
         this.messageToBeTransmitted = new Subject()
         this.retransmission = new RetransmissionService()
         this.setTransmitter(profile)
-        this.setUpAdapter(adapterSets)
+        this.setUpAdapter(adapter)
         this.setUpRetransmission()
     }
     
@@ -44,7 +45,7 @@ export class MessageTransmissionTransmitter extends MessageTransmissionBase impl
         // automatically subscribe to allow released bffered messages to be released
         this.retransmission.returnSubjectForBufferedItems().subscribe((message: WrappedMessage) => {
             // need to work with wrapped messages
-            (this.adapterService as TransmitterConnectionAdapter).emit(message)
+            (this.mainAdapter as TransmitterConnectionAdapter).emit(message)
         })
     }
     
@@ -57,14 +58,9 @@ export class MessageTransmissionTransmitter extends MessageTransmissionBase impl
         this.messageToBeTransmitted.next(message)
     }
 
-    setUpAdapter(adapterSets: AdapterSet[]) {
-        if (adapterSets.length > 0) {
-            adapterSets.forEach((adapter: AdapterSet) => {
-                this.adaptorsArray.push(adapter.transmitterAdapter)
-            })
-        }
+    setUpAdapter(adapter: ConnectionAdapter): void {
         // for now just hardcode to use 1 adapter type until connection manager is further enhacne to configure adapters on the fly
-        this.adapterService = this.adaptorsArray.find(obj => obj.getInfo().transportType === Transport.Websocket)
+        this.mainAdapter = adapter
     }
 
 }

+ 6 - 11
src/utils/http.utils.ts

@@ -22,12 +22,6 @@ export function startHttpServer(port: number): Observable<ConnectedHttpClient> {
             res.send('Hello, World!');
         });
 
-        // Handling a POST request
-        app.post('/data', (req, res) => {
-            const { name, age } = req.body;
-            res.json({ message: `Received data: ${name}, ${age}` });
-        });
-
         app.listen(port, () => {
             console.log(`Server running at http://localhost:${port}`);
         });
@@ -55,7 +49,7 @@ export async function initiateClientToServer(url: string, event: Subject<Transpo
             if (clientName) {
                 checkOwnClientInfo(clientName).then((profile: ConnectedHttpServer) => {
                     receiverProfileInfo = profile
-                    postAxiosRequest(url + 'profile', { name: 'Old Client', data: profile }).then((profileInfo: any) => {
+                    postAxiosRequest(url + '/profile', { name: 'Old Client', data: profile }).then((profileInfo: any) => {
                         writeFile(profileInfo.message, (profileInfo.message as ConnectedHttpServer).id).then((data: any) => {
                             console.log(`Assigned client Name: ${(data.message as ConnectedHttpServer).id}`)
                             receiverProfileInfo = data.message as ConnectedHttpServer
@@ -79,7 +73,7 @@ export async function initiateClientToServer(url: string, event: Subject<Transpo
                         })
                     })
                 }).catch((error) => {
-                    postAxiosRequest(url + 'profile', { name: 'New Client', data: null }).then((profileInfo: any) => {
+                    postAxiosRequest(url + '/profile', { name: 'New Client', data: null }).then((profileInfo: any) => {
                         updateProfileAndPublishEvent(clientName, receiverProfileInfo, profileInfo, event, connectedHttpServers).then((receiverProfileInfo) => {
                             resolve(receiverProfileInfo)
                         })
@@ -89,7 +83,7 @@ export async function initiateClientToServer(url: string, event: Subject<Transpo
                     reject(error)
                 })
             } else {
-                postAxiosRequest(url + 'profile', { name: 'New Client', data: null }).then((profileInfo: any) => {
+                postAxiosRequest(url + '/profile', { name: 'New Client', data: null }).then((profileInfo: any) => {
                     updateProfileAndPublishEvent(clientName, receiverProfileInfo, profileInfo, event, connectedHttpServers).then((receiverProfileInfo) => {
                         resolve(receiverProfileInfo)
                     })
@@ -200,7 +194,7 @@ export function handleHttpClient(clientInfo: ConnectedHttpClient, connectedClien
     })
 }
 
-export function handleProfile(app: Express, data: { name: `Old Client` | `New Client`, message: any }, res: Response, event: Observer<TransportEvent>, connectedClientHttp: ConnectedHttpClient[]): void {
+function handleProfile(app: Express, data: { name: `Old Client` | `New Client`, message: any }, res: Response, event: Observer<TransportEvent>, connectedClientHttp: ConnectedHttpClient[]): void {
     if (data.name == `New Client`) {
         let clientInstance: ConnectedHttpClient = {
             id: uuidv4(), // client should only be assigned at this level. And is passed around for reference pointing
@@ -212,7 +206,7 @@ export function handleProfile(app: Express, data: { name: `Old Client` | `New Cl
 
         // send to receiver for reference
         res.json({
-            name: `New Client`, message: { id: clientInstance.id }
+            name: `New Profile`, message: { id: clientInstance.id }
         })
         // publish first event notification
         event.next({
@@ -356,6 +350,7 @@ export function startListeningAndStreaming(app: Express, client: ConnectedHttpCl
 
     app.get('/poll', (req, res) => {
         console.log('Client connected for long polling.');
+        client.connectionState.next(`ONLINE`)
 
         // Subscribe to the data stream
         const subscription: Subscription = client.responseStream.asObservable().subscribe({