whio-api-sdk 1.1.5 → 1.1.6
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.
|
@@ -52,16 +52,18 @@ export class WebSocketModule extends BaseClient {
|
|
|
52
52
|
this.emit('connection-error', new Error('No access token available for WebSocket connection'));
|
|
53
53
|
throw new Error('No access token available for WebSocket connection');
|
|
54
54
|
}
|
|
55
|
+
// Create socket with autoConnect: false to prevent immediate connection
|
|
55
56
|
this.socket = io(wsUrl, {
|
|
56
57
|
auth: {
|
|
57
58
|
token: token
|
|
58
59
|
},
|
|
59
60
|
forceNew: true,
|
|
60
|
-
timeout: 10000
|
|
61
|
+
timeout: 10000,
|
|
62
|
+
autoConnect: false // Prevent automatic connection
|
|
61
63
|
});
|
|
62
64
|
this.setupEventHandlers();
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
+
// Set up connection promise BEFORE connecting
|
|
66
|
+
const connectionPromise = new Promise((resolve, reject) => {
|
|
65
67
|
const timeout = setTimeout(() => {
|
|
66
68
|
reject(new Error('WebSocket connection timeout after 10 seconds'));
|
|
67
69
|
}, 10000);
|
|
@@ -80,6 +82,10 @@ export class WebSocketModule extends BaseClient {
|
|
|
80
82
|
this.socket.once('connect', onConnect);
|
|
81
83
|
this.socket.once('connect_error', onError);
|
|
82
84
|
});
|
|
85
|
+
// Now initiate the connection
|
|
86
|
+
this.socket.connect();
|
|
87
|
+
// Wait for connection to complete
|
|
88
|
+
yield connectionPromise;
|
|
83
89
|
}
|
|
84
90
|
catch (error) {
|
|
85
91
|
this.emit('connection-error', error);
|
package/package.json
CHANGED
|
@@ -71,18 +71,20 @@ export class WebSocketModule extends BaseClient {
|
|
|
71
71
|
throw new Error('No access token available for WebSocket connection');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// Create socket with autoConnect: false to prevent immediate connection
|
|
74
75
|
this.socket = io(wsUrl, {
|
|
75
76
|
auth: {
|
|
76
77
|
token: token
|
|
77
78
|
},
|
|
78
79
|
forceNew: true,
|
|
79
|
-
timeout: 10000
|
|
80
|
+
timeout: 10000,
|
|
81
|
+
autoConnect: false // Prevent automatic connection
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
this.setupEventHandlers();
|
|
83
85
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
+
// Set up connection promise BEFORE connecting
|
|
87
|
+
const connectionPromise = new Promise<void>((resolve, reject) => {
|
|
86
88
|
const timeout = setTimeout(() => {
|
|
87
89
|
reject(new Error('WebSocket connection timeout after 10 seconds'));
|
|
88
90
|
}, 10000);
|
|
@@ -102,6 +104,12 @@ export class WebSocketModule extends BaseClient {
|
|
|
102
104
|
this.socket!.once('connect', onConnect);
|
|
103
105
|
this.socket!.once('connect_error', onError);
|
|
104
106
|
});
|
|
107
|
+
|
|
108
|
+
// Now initiate the connection
|
|
109
|
+
this.socket.connect();
|
|
110
|
+
|
|
111
|
+
// Wait for connection to complete
|
|
112
|
+
await connectionPromise;
|
|
105
113
|
} catch (error) {
|
|
106
114
|
this.emit('connection-error', error as Error);
|
|
107
115
|
throw error;
|