Skip to content

Commit

Permalink
Fix sending sequences info on platform connect 2
Browse files Browse the repository at this point in the history
  • Loading branch information
patuwwy committed Jan 24, 2024
1 parent 0afc685 commit 0704147
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
8 changes: 3 additions & 5 deletions packages/host/src/lib/cpm-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export class CPMConnector extends TypedEmitter<Events> {

return message;
}).catch((e: any) => {
this.logger.error("communicationChannel error", e.message);
this.logger.warn("communicationChannel error", e.message);
});

this.communicationStream = new StringStream().JSONStringify().resume();
Expand Down Expand Up @@ -386,7 +386,7 @@ export class CPMConnector extends TypedEmitter<Events> {
});

this.verserClient.once("error", async (error: any) => {
this.logger.error("VerserClient error", error);
this.logger.warn("VerserClient error", error);

try {
await this.reconnect();
Expand All @@ -408,9 +408,7 @@ export class CPMConnector extends TypedEmitter<Events> {
this.connection?.removeAllListeners();
this.connected = false;

this.logger.trace("Tunnel closed", this.getId());

this.logger.info("CPM connection closed.");
this.logger.info("CPM connection closed.", connectionStatusCode, this.getId());

if (this.loadInterval) {
clearInterval(this.loadInterval);
Expand Down
2 changes: 1 addition & 1 deletion packages/host/src/lib/csi-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class CSIDispatcher extends TypedEmitter<Events> {
csiController.outputRouted = true;

await this.serviceDiscovery.update({
provides: data.provides, contentType: data.contentType!, topicName: data.provides, status: "add"
localProvider: csiController.id, provides: data.provides, contentType: data.contentType!, topicName: data.provides, status: "add"
});
}
})
Expand Down
17 changes: 1 addition & 16 deletions packages/host/src/lib/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,22 +601,7 @@ export class Host implements IComponent {
connector.init();

connector.on("connect", async () => {
await defer(3000);
//await connector.sendSequencesInfo(this.getSequences());
await Promise.all(
this.getSequences()
.map(
s =>
connector.sendSequenceInfo(
s.id,
SequenceMessageCode.SEQUENCE_CREATED,
{
...s.config,
location: this.getId()!
} as unknown as STHRestAPI.GetSequenceResponse
)
)
);
await connector.sendSequencesInfo(this.getSequences().map(s => ({ ...s, status: SequenceMessageCode.SEQUENCE_CREATED })));
await connector.sendInstancesInfo(this.getInstances());
await connector.sendTopicsInfo(this.getTopics());

Expand Down
2 changes: 1 addition & 1 deletion packages/host/test/serviceDiscovery/sd-discovery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ beforeEach(() => {
serviceDiscovery.cpmConnector = {
sendTopicInfo: (data: AddSTHTopicEventData): Promise<void> => {
topicInfo = data;
return new Promise((resolve) => resolve());
return Promise.resolve();
}
} as CPMConnector;
});
Expand Down

0 comments on commit 0704147

Please sign in to comment.