Skip to content

Commit 1178c70

Browse files
committed
fix reconnect, bump version
1 parent 7b64c92 commit 1178c70

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

OpenFlowNodeRED/src/WebSocketClient.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class WebSocketClient {
4141
WebSocketClient.instance = this;
4242
}
4343

44-
setInterval(this.pingServer, 10000);
44+
setInterval(this.pingServer.bind(this), 10000);
4545
}
4646
public connect(): void {
4747
try {
@@ -80,20 +80,19 @@ export class WebSocketClient {
8080
return true;
8181
}
8282
private pingServer(): void {
83-
var me: WebSocketClient = WebSocketClient.instance;
8483
try {
85-
if (me._socketObject !== null && me._socketObject.readyState === me._socketObject.OPEN) {
84+
if (this._socketObject !== null && this._socketObject.readyState === this._socketObject.OPEN) {
8685
let msg: SocketMessage = SocketMessage.fromcommand("ping");
87-
me._socketObject.send(JSON.stringify(msg));
86+
this._socketObject.send(JSON.stringify(msg));
8887
}
89-
if (me._socketObject === null ||
90-
me._socketObject.readyState !== me._socketObject.CONNECTING || me._socketObject.readyState !== me._socketObject.OPEN) {
91-
me.connect();
88+
if (this._socketObject === null ||
89+
this._socketObject.readyState !== this._socketObject.CONNECTING || this._socketObject.readyState !== this._socketObject.OPEN) {
90+
this.connect();
9291
}
9392
} catch (error) {
94-
me._logger.error(error.message);
93+
this._logger.error(error.message);
9594
console.error(error);
96-
me.connect();
95+
this.connect();
9796
}
9897
}
9998
private async onopen(evt: Event): Promise<void> {

OpenFlowNodeRED/src/nodered/nodes/NoderedUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export class NoderedUtil {
329329
});
330330
}
331331
public static async QueueMessage(websocket: WebSocketClient, queuename: string, replyto: string, data: any, correlationId: string, expiration: number): Promise<void> {
332-
if (!WebSocketClient.instance.isConnected()) throw new Error("Cannot send, not connected");
332+
if (!websocket.isConnected()) throw new Error("Cannot send, not connected");
333333
await this._QueueMessage(websocket, queuename, replyto, data, correlationId, expiration);
334334
}
335335
}

OpenFlowNodeRED/src/nodered/nodes/amqp_nodes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ export class amqp_publisher_node {
237237
// if (this.localqueue !== null && this.localqueue !== undefined && this.localqueue !== "") { this.localqueue = Config.queue_prefix + this.localqueue; }
238238
var expiration: number = Config.amqp_workflow_out_expiration;
239239
if (!NoderedUtil.IsNullEmpty(msg.expiration)) expiration = msg.expiration;
240+
this.node.status({ fill: "blue", shape: "dot", text: "Sending message ..." });
240241
await NoderedUtil.QueueMessage(this.websocket, queue, this.localqueue, data, null, expiration);
241242
// this.con.SendMessage(JSON.stringify(data), this.config.queue, null, true);
242-
this.node.status({});
243+
this.node.status({ fill: "green", shape: "dot", text: "Connected" });
243244
} catch (error) {
244245
NoderedUtil.HandleError(this, error);
245246
}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.577
1+
1.0.1

0 commit comments

Comments
 (0)