socket-function 1.1.16 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/CallFactory.d.ts +1 -0
- package/src/CallFactory.ts +15 -1
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/CallFactory.d.ts
CHANGED
package/src/CallFactory.ts
CHANGED
|
@@ -44,6 +44,7 @@ type InternalReturnType = {
|
|
|
44
44
|
|
|
45
45
|
export interface CallFactory {
|
|
46
46
|
nodeId: string;
|
|
47
|
+
realNodeId?: string;
|
|
47
48
|
lastClosed: number;
|
|
48
49
|
closedForever?: boolean;
|
|
49
50
|
isConnected?: boolean;
|
|
@@ -53,6 +54,7 @@ export interface CallFactory {
|
|
|
53
54
|
performCall(call: CallType): Promise<unknown>;
|
|
54
55
|
onNextDisconnect(callback: () => void): void;
|
|
55
56
|
disconnect(): void;
|
|
57
|
+
// If we change the node ID we need to recreate this object, essentially this object should be immutable. I forget why we wanted this. I think it's because we didn't know for sure if node ID would be unique, but it will be.
|
|
56
58
|
connectionId: { nodeId: string };
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -161,6 +163,8 @@ export async function createCallFactory(
|
|
|
161
163
|
receivedInitializeState: undefined,
|
|
162
164
|
onNextDisconnect,
|
|
163
165
|
disconnect() {
|
|
166
|
+
canReconnect = false;
|
|
167
|
+
callFactory.closedForever = true;
|
|
164
168
|
if (webSocketPromise) {
|
|
165
169
|
webSocketPromise.then(ws => ws.close()).catch(() => { });
|
|
166
170
|
}
|
|
@@ -557,6 +561,10 @@ export async function createCallFactory(
|
|
|
557
561
|
if (!SocketFunction.LEGACY_INITIALIZE && call.seqNum === INITIALIZE_STATE_SEQ_NUM) {
|
|
558
562
|
callFactory.receivedInitializeState = call.result as InitializeState;
|
|
559
563
|
let otherReconnectionUrl = callFactory.receivedInitializeState.ownReconnectionUrl;
|
|
564
|
+
callFactory.realNodeId = otherReconnectionUrl;
|
|
565
|
+
if (SocketFunction.logMessages) {
|
|
566
|
+
console.log(green(`Received initialize state from ${callFactory.realNodeId} at ${Date.now()}`));
|
|
567
|
+
}
|
|
560
568
|
if (otherReconnectionUrl && !canReconnect && !!getNodeIdLocation(otherReconnectionUrl) && otherReconnectionUrl !== ownReconnectionUrl) {
|
|
561
569
|
if (changeNodeId({
|
|
562
570
|
originalNodeId: nodeId,
|
|
@@ -568,7 +576,7 @@ export async function createCallFactory(
|
|
|
568
576
|
callerContext.nodeId = nodeId;
|
|
569
577
|
canReconnect = !!getNodeIdLocation(nodeId);
|
|
570
578
|
callFactory.nodeId = nodeId;
|
|
571
|
-
callFactory.connectionId
|
|
579
|
+
callFactory.connectionId = { nodeId };
|
|
572
580
|
}
|
|
573
581
|
}
|
|
574
582
|
return;
|
|
@@ -790,8 +798,14 @@ export async function createCallFactory(
|
|
|
790
798
|
result: initState,
|
|
791
799
|
seqNum: INITIALIZE_STATE_SEQ_NUM,
|
|
792
800
|
};
|
|
801
|
+
if (SocketFunction.logMessages) {
|
|
802
|
+
console.log(`Sending initialize state to ${nodeId}`);
|
|
803
|
+
}
|
|
793
804
|
let data = await SocketFunction.WIRE_SERIALIZER.serialize(initReturn);
|
|
794
805
|
await send(data);
|
|
806
|
+
if (SocketFunction.logMessages) {
|
|
807
|
+
console.log(`Sent initialize state to ${nodeId}`);
|
|
808
|
+
}
|
|
795
809
|
}
|
|
796
810
|
|
|
797
811
|
return callFactory;
|