Enzo 1 неделя назад
Родитель
Сommit
c748986229

+ 0 - 3
468076d5-1a00-4861-b6c9-8e369103dc8e.json

@@ -1,3 +0,0 @@
-{
-  "id": "468076d5-1a00-4861-b6c9-8e369103dc8e"
-}

+ 0 - 3
5157e5f6-291e-4464-8cf8-9cd19f624b30.json

@@ -1,3 +0,0 @@
-{
-  "id": "5157e5f6-291e-4464-8cf8-9cd19f624b30"
-}

+ 0 - 3
ecd7a4ef-420e-48d4-be15-8bae649cd9e6.json

@@ -1,3 +0,0 @@
-{
-  "id": "ecd7a4ef-420e-48d4-be15-8bae649cd9e6"
-}

+ 2 - 1
src/connector/connector.manager.ts

@@ -25,13 +25,14 @@ export class ConnectionManager implements ConnectionManagerInterface {
 
         // Everything that happens will go through here. Can also plug in logging service here at a later time
         this.transportEvent.subscribe((event: TransportEvent) => {
-            console.log(`TranpsortEvent: `, event)
+            console.log(`TransportEvent: `, event)
             if (event.event == 'New Client') {
                 this.handleNewClient((event.data as EventMessage).payload) // payload is connectedclientInstance
             }
         })
     }
 
+    // alternatives. Though the transmission instances have their own set of pointers
     getAdapterSetById(adapterSetid: string): AdapterSet {
         let adapterSet: AdapterSet | undefined = this.adapterSet.find(obj => obj.id === adapterSetid)
         if (adapterSet) {

+ 1 - 0
src/test/transmitter.ts

@@ -17,6 +17,7 @@ class Application {
         this.transmissionInstance = this.messageTransmissionManager.getTransmissionInstance()
 
         this.generateNotifcation().subscribe(this.generalNotification)
+        this.subscribeForNewClientWhoWantsNotification()
     }
 
     // Emulating request response. For the case where this transmitter is acting as a receiver

+ 7 - 1
src/transport/websocket.ts

@@ -3,6 +3,7 @@ import { Socket as ClientSocket } from 'socket.io-client'
 import { Socket as SocketForConnectedClient } from "socket.io"
 import { handleClientSocketConnection, handleNewSocketClient, startClientSocketConnection, startSocketServer } from "../utils/socket.utils";
 import { ClientObject, ConnectionState, Info, Transport, TransportEvent, TransportMessage, TransportService } from "../interface/connector.interface";
+import { error } from "console";
 
 /* Just code in the context that this websocket service will be handling multiple UI clients. Can think about the server communication at a later time. */
 export class WebsocketTransportService implements TransportService {
@@ -22,9 +23,14 @@ export class WebsocketTransportService implements TransportService {
         startSocketServer(port).subscribe({
             next: (connectedClient: SocketForConnectedClient) => {
                 console.log(`WebsocketTransport Server Started...`)
-                handleNewSocketClient(connectedClient, this.connectedClientSocket).subscribe(this.transportEvent)
+                handleNewSocketClient(connectedClient, this.connectedClientSocket).subscribe({
+                    next: event => this.transportEvent.next(event),
+                    error: error => console.error(error),
+                    complete: () => console.log(`Client ${connectedClient.id} disconnected...`)
+                }) 
             },
             error: error => console.error(error),
+            complete: () => console.log(`...`)
         })
     }