Parcourir la source

retransmission without mongo fix

Enzo il y a 11 mois
Parent
commit
41f879a3d6

+ 0 - 2
interfaces/general.interface.ts

@@ -35,7 +35,6 @@ export interface Message {
 }
 
 export type State = -1 | 0 | 1 // For status chain effect
-export type ConnectionStatus = `ON` | `OFF`
 
 export interface ConnectionAttribute {
     ConnectionID: ConnectionID,
@@ -50,7 +49,6 @@ export interface StreamAttribute {
     PublisherInstance?: any,
     SubscriberInstance?: any,
     serverUrl?: string,
-    connectionState?: ConnectionStatus,
     MessageToBePublished: Observable<Message> | null
     MessageToBeReceived: Subject<Message> | null
 }

+ 7 - 7
services/grpc.service.method.ts

@@ -143,12 +143,6 @@ export class GrpcServiceMethod {
                         payload: this.messageToBeSendOver ?? `There's no message at the moment...`
                     }
                     connectionAttribute.connectionStatus!.next(report)
-                    let clientStatusUpdateInfo: any = {
-                        connectionStatus: 'OFF',
-                        connectionID: connectionAttribute.ConnectionID.remote,
-                        message: `${connectionAttribute.outGoing.serverUrl} started.`
-                    }
-                    this.clientRequest.next(clientStatusUpdateInfo)
                     resolve('No connection established. Server is not responding..')
                 }
             });
@@ -164,7 +158,13 @@ export class GrpcServiceMethod {
             });
 
             call.on('error', (err) => {
-                console.error(err)
+                // console.error(err)
+                let report: ConnectionState = {
+                    status: 'BUFFER',
+                    reason: `Server doesn't seem to be alive. Error returned.`,
+                    payload: this.messageToBeSendOver ?? `There's no message at the moment...`
+                }
+                connectionAttribute.connectionStatus!.next(report)
                 resolve('')
             });
         })

+ 0 - 2
services/server-client.service.ts

@@ -76,7 +76,6 @@ export class ServerClientManager {
                         PublisherID: request.server!.name,
                         SubscriberID: request.server!.name,
                         serverUrl: request.server?.serverUrl,
-                        connectionState: `OFF`,
                         MessageToBePublished: retransmission!.getMessages(),
                         MessageToBeReceived: null
                     },
@@ -85,7 +84,6 @@ export class ServerClientManager {
                         PublisherID: request.client!.name,
                         SubscriberID: request.client!.name,
                         serverUrl: request.client?.targetServer,
-                        connectionState: `OFF`,
                         MessageToBePublished: null,
                         MessageToBeReceived: request.client!.messageToBeReceivedFromRemote
                     },

+ 16 - 15
test/grpc1.ts

@@ -16,7 +16,7 @@ let targetserver: string = 'localhost:3001'
 let targetserver2: string = 'localhost:3002'
 let hostServer: string = 'localhost:3000'
 let array: any[] = [] // Used for testing    
-let intervalToStreamOutGoingMessage: number = 1
+let intervalToStreamOutGoingMessage: number = 15
 
 
 /* Simple Test: 1 to 1 */
@@ -178,24 +178,25 @@ generateFakeMessagesToBePublished.subscribe({
       id: hostServer,
       message: message
     }
-    connectionRequest1.server!.messageToBePublishedFromApplication.next(payload)
-    connectionRequest2.server!.messageToBePublishedFromApplication.next(payload)
+    // connectionRequest1.server!.messageToBePublishedFromApplication.next(payload)
+    // connectionRequest2.server!.messageToBePublishedFromApplication.next(payload)
   },
   error: error => console.error(error),
   complete: () => console.log(`Completed`)
 })
 
-// let generateFakeMessagesToBePublished = stream().pipe(take(10))
-// generateFakeMessagesToBePublished.subscribe({
-//   next: message => {
-//     let payload: Message = {
-//       id: hostServer,
-//       message: message
-//     }
-//     connectionRequest.server.messageToBePublishedFromApplication.next(payload)
-//     connectionRequest2.server.messageToBePublishedFromApplication.next(payload)
-//   }
-// })
+
+stream().subscribe({
+  next: message => {
+    let payload = {
+      id: hostServer,
+      message: message
+    }
+    connectionRequest1.server!.messageToBePublishedFromApplication.next(payload)
+    connectionRequest2.server!.messageToBePublishedFromApplication.next(payload)
+  }
+})
+
 
 // connectionRequest.client.messageToBeReceivedFromRemote.subscribe({
 //   next: request => {
@@ -328,7 +329,7 @@ function stream(): Subject<any> {
   const intervalId = setInterval(() => {
     result.next(messages[count]);
     count++;
-    if (count >= 1000) {
+    if (count >= 300) {
       clearInterval(intervalId);
       result.complete();
     }