|
@@ -11,11 +11,9 @@ export class GrpcServiceMethod {
|
|
private callRequestsFromRemote: ServerWritableStreamImpl<any, ResponseType>[] = []
|
|
private callRequestsFromRemote: ServerWritableStreamImpl<any, ResponseType>[] = []
|
|
|
|
|
|
public async create(request: ConnectionRequest, connectionAttribute: ConnectionAttribute): Promise<any> {
|
|
public async create(request: ConnectionRequest, connectionAttribute: ConnectionAttribute): Promise<any> {
|
|
-
|
|
|
|
// Assuming currently only one client
|
|
// Assuming currently only one client
|
|
this.createGrpcInstance(request.server.serverUrl, { instanceType: 'server' }, connectionAttribute)
|
|
this.createGrpcInstance(request.server.serverUrl, { instanceType: 'server' }, connectionAttribute)
|
|
this.createGrpcInstance(request.client.targetServer, { instanceType: 'client' }, connectionAttribute)
|
|
this.createGrpcInstance(request.client.targetServer, { instanceType: 'client' }, connectionAttribute)
|
|
- // connectionAttribute.outGoing.MessageToBePublished?.subscribe(e => console.log((e.message as MessageLog).appData.msgId))
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// For testing only
|
|
// For testing only
|
|
@@ -50,11 +48,6 @@ export class GrpcServiceMethod {
|
|
if (connectionAttribute.outGoing.StreamID && connectionAttribute.inComing.StreamID) {
|
|
if (connectionAttribute.outGoing.StreamID && connectionAttribute.inComing.StreamID) {
|
|
connectionAttribute.ConnectionID.local = connectionAttribute.outGoing.StreamID + connectionAttribute.inComing.StreamID
|
|
connectionAttribute.ConnectionID.local = connectionAttribute.outGoing.StreamID + connectionAttribute.inComing.StreamID
|
|
connectionAttribute.ConnectionID.remote = connectionAttribute.inComing.StreamID + connectionAttribute.outGoing.StreamID
|
|
connectionAttribute.ConnectionID.remote = connectionAttribute.inComing.StreamID + connectionAttribute.outGoing.StreamID
|
|
- // let report: ReportStatus = {
|
|
|
|
- // code: ColorCode.GREEN,
|
|
|
|
- // message: `ConnectionID acquired. Informing Restranmission to release Messages...`,
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,10 +84,6 @@ export class GrpcServiceMethod {
|
|
if (redErrorEmission == false) {
|
|
if (redErrorEmission == false) {
|
|
redErrorEmission = true
|
|
redErrorEmission = true
|
|
console.error(`Connection failed ${consecutiveResolutions} times. Stopping connection attempts.`);
|
|
console.error(`Connection failed ${consecutiveResolutions} times. Stopping connection attempts.`);
|
|
- // let error: ReportStatus = {
|
|
|
|
- // code: ColorCode.YELLOW,
|
|
|
|
- // message: 'Server is not responding. Proceed to buffer.',
|
|
|
|
- // }
|
|
|
|
let error: ConnectionState = {
|
|
let error: ConnectionState = {
|
|
status: 'BUFFER',
|
|
status: 'BUFFER',
|
|
reason: `Server is not responding...`
|
|
reason: `Server is not responding...`
|
|
@@ -207,7 +196,6 @@ export class GrpcServiceMethod {
|
|
}
|
|
}
|
|
this.generateAdditionalAttributes(connectionAttribute, {}, outGoingInfo)
|
|
this.generateAdditionalAttributes(connectionAttribute, {}, outGoingInfo)
|
|
|
|
|
|
- // connectionAttribute.ConnectionID = connectionAttribute.outGoing.ChannelID + (connectionAttribute.inComing.ChannelID ?? 'undefined')
|
|
|
|
let call = client.HandleMessage({ id: server, message: JSON.stringify(outGoingInfo) })
|
|
let call = client.HandleMessage({ id: server, message: JSON.stringify(outGoingInfo) })
|
|
console.log(`Sending request to ${server} to open response channel...`)
|
|
console.log(`Sending request to ${server} to open response channel...`)
|
|
|
|
|
|
@@ -216,11 +204,6 @@ export class GrpcServiceMethod {
|
|
console.log(`Message trasmission operation is successful`)
|
|
console.log(`Message trasmission operation is successful`)
|
|
// RPC completed successfully
|
|
// RPC completed successfully
|
|
} if (status == grpc.status.UNAVAILABLE) {
|
|
} if (status == grpc.status.UNAVAILABLE) {
|
|
- // let report: ReportStatus = {
|
|
|
|
- // code: ColorCode.YELLOW,
|
|
|
|
- // message: `Server doesn't seem to be alive. Error returned.`,
|
|
|
|
- // payload: this.messageToBeSendOver ?? `There's no message at the moment...`
|
|
|
|
- // }
|
|
|
|
let report: ConnectionState = {
|
|
let report: ConnectionState = {
|
|
status: 'BUFFER',
|
|
status: 'BUFFER',
|
|
reason: `Server doesn't seem to be alive. Error returned.`,
|
|
reason: `Server doesn't seem to be alive. Error returned.`,
|
|
@@ -239,7 +222,6 @@ export class GrpcServiceMethod {
|
|
if (connectionAttribute.inComing.MessageToBeReceived) {
|
|
if (connectionAttribute.inComing.MessageToBeReceived) {
|
|
connectionAttribute.inComing.MessageToBeReceived.next(response)
|
|
connectionAttribute.inComing.MessageToBeReceived.next(response)
|
|
}
|
|
}
|
|
- // console.log(`Received ${(response.message as MessageLog).appData.msgId}`)
|
|
|
|
});
|
|
});
|
|
|
|
|
|
call.on('error', (err) => {
|
|
call.on('error', (err) => {
|