|
@@ -8,11 +8,11 @@ import { ServerClientManager } from '../services/server-client.service';
|
|
const connectionService: ServerClientManager = new ServerClientManager(new GrpcServiceMethod())
|
|
const connectionService: ServerClientManager = new ServerClientManager(new GrpcServiceMethod())
|
|
const messagesJSON: any = readFileSync('payload.json')
|
|
const messagesJSON: any = readFileSync('payload.json')
|
|
let parsedMessages: any[] = JSON.parse(messagesJSON) // load the fake messages generated for this trial
|
|
let parsedMessages: any[] = JSON.parse(messagesJSON) // load the fake messages generated for this trial
|
|
-let targetserver: string = 'localhost:300'
|
|
|
|
-// let targetserver2: string = 'localhost:3002'
|
|
|
|
|
|
+let targetserver: string = 'localhost:3001'
|
|
|
|
+let targetserver2: string = 'localhost:3002'
|
|
let hostServer: string = 'localhost:3002'
|
|
let hostServer: string = 'localhost:3002'
|
|
let array: any[] = [] // Used for testing
|
|
let array: any[] = [] // Used for testing
|
|
-let request: ConnectionRequest = {
|
|
|
|
|
|
+let connectionRequest: ConnectionRequest = {
|
|
server: {
|
|
server: {
|
|
serverUrl: hostServer,
|
|
serverUrl: hostServer,
|
|
connectionType: 'GRPC',
|
|
connectionType: 'GRPC',
|
|
@@ -22,22 +22,22 @@ let request: ConnectionRequest = {
|
|
targetServer: targetserver,
|
|
targetServer: targetserver,
|
|
connectionType: 'GRPC',
|
|
connectionType: 'GRPC',
|
|
messageToBeReceivedFromRemote: new Subject<Message>()
|
|
messageToBeReceivedFromRemote: new Subject<Message>()
|
|
- },
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Handler for the incoming Messages from the other side.
|
|
// Handler for the incoming Messages from the other side.
|
|
-request.client.messageToBeReceivedFromRemote.subscribe({
|
|
|
|
|
|
+connectionRequest.client.messageToBeReceivedFromRemote.subscribe({
|
|
next: request => {
|
|
next: request => {
|
|
// Application logic comes here. This is where the asortment takes place, of decidiing whose messages it belongs of what it is
|
|
// Application logic comes here. This is where the asortment takes place, of decidiing whose messages it belongs of what it is
|
|
if ((request.message as MessageLog).appData.msgPayload == 'Query') {
|
|
if ((request.message as MessageLog).appData.msgPayload == 'Query') {
|
|
generateFakeStreamResponse(request).subscribe({
|
|
generateFakeStreamResponse(request).subscribe({
|
|
- next: (responseMessage) => {
|
|
|
|
|
|
+ next: (responseMessage: Message) => {
|
|
// console.log(`Processing request:${request.id}....`)
|
|
// console.log(`Processing request:${request.id}....`)
|
|
- request.server.messageToBePublishedfromApplication.next(responseMessage)
|
|
|
|
|
|
+ connectionRequest.server.messageToBePublishedfromApplication.next(responseMessage)
|
|
},
|
|
},
|
|
error: error => console.error(error),
|
|
error: error => console.error(error),
|
|
complete: () => {
|
|
complete: () => {
|
|
- console.log(`Stream request for ${request.id} is queued.`) // should be indefinite
|
|
|
|
|
|
+ console.log(`Stream request for ${request.id} is queued.`) // shpuld be indefinite
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
@@ -51,24 +51,35 @@ request.client.messageToBeReceivedFromRemote.subscribe({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-connectionService.generateConnection(request)
|
|
|
|
-// grpcService.createGrpcInstance(hostServer, { instanceType: 'server', serviceMethod: 'server streaming' }, messageToBeReleased)
|
|
|
|
|
|
+connectionService.generateConnection(connectionRequest)
|
|
|
|
+
|
|
|
|
+/* Simple Test */
|
|
|
|
+// let generateFakeMessagesToBePublished = stream().pipe(take(10))
|
|
|
|
+// generateFakeMessagesToBePublished.subscribe({
|
|
|
|
+// next: message => {
|
|
|
|
+// let payload: Message = {
|
|
|
|
+// id: hostServer,
|
|
|
|
+// message: JSON.stringify(message)
|
|
|
|
+// }
|
|
|
|
+// connectionRequest.server.messageToBePublishedfromApplication.next(payload)
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
|
|
-// grpcService.createGrpcInstance(targetserver, { instanceType: 'client', serviceMethod: 'server streaming' })
|
|
|
|
|
|
|
|
|
|
+/* Complex Test */
|
|
// setTimeout(() => {
|
|
// setTimeout(() => {
|
|
// let message = {
|
|
// let message = {
|
|
// id: parsedMessages[10].appData.msgId,
|
|
// id: parsedMessages[10].appData.msgId,
|
|
// message: parsedMessages[10] // Choose this number, because i purposely use the 11th message and change the msgPayload property to query to emulate a request
|
|
// message: parsedMessages[10] // Choose this number, because i purposely use the 11th message and change the msgPayload property to query to emulate a request
|
|
// }
|
|
// }
|
|
-// applicationOutgoingResponse.next(message)
|
|
|
|
|
|
+// connectionRequest.server.messageToBePublishedfromApplication.next(message)
|
|
// }, 3000)
|
|
// }, 3000)
|
|
// setTimeout(() => {
|
|
// setTimeout(() => {
|
|
// let message = {
|
|
// let message = {
|
|
// id: parsedMessages[11].appData.msgId,
|
|
// id: parsedMessages[11].appData.msgId,
|
|
// message: parsedMessages[11]// Choose this number, because i purposely use the 11th message and change the msgPayload property to query to emulate a request
|
|
// message: parsedMessages[11]// Choose this number, because i purposely use the 11th message and change the msgPayload property to query to emulate a request
|
|
// }
|
|
// }
|
|
-// applicationOutgoingResponse.next(message)
|
|
|
|
|
|
+// connectionRequest.server.messageToBePublishedfromApplication.next(message)
|
|
// }, 4000)
|
|
// }, 4000)
|
|
// setTimeout(() => {
|
|
// setTimeout(() => {
|
|
// console.log(`All received data: ${array.length}`)
|
|
// console.log(`All received data: ${array.length}`)
|