@symbo.ls/socket 2.11.16 → 2.11.38
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/client.js +10 -5
- package/package.json +2 -2
package/client.js
CHANGED
|
@@ -12,11 +12,13 @@ const ENV = process.env.NODE_ENV
|
|
|
12
12
|
const SOCKET_BACKEND_URL = window && window.location &&
|
|
13
13
|
window.location.host.includes('local')
|
|
14
14
|
? 'localhost:13335'
|
|
15
|
-
: '
|
|
15
|
+
: 'socket.symbols.app' ||
|
|
16
16
|
'https://socket.symbols.app'
|
|
17
17
|
|
|
18
18
|
let socket
|
|
19
|
+
let tryConnect = 0
|
|
19
20
|
const defautlOpts = {}
|
|
21
|
+
const tryConnectMax = 1
|
|
20
22
|
|
|
21
23
|
export const connect = (key, options = {}) => {
|
|
22
24
|
const socketUrls = isArray(options.socketUrl)
|
|
@@ -40,21 +42,25 @@ export const connect = (key, options = {}) => {
|
|
|
40
42
|
socket.emit('initConnect', options)
|
|
41
43
|
|
|
42
44
|
try {
|
|
43
|
-
if (isFunction(options.onConnect))
|
|
45
|
+
if (isFunction(options.onConnect)) {
|
|
46
|
+
options.onConnect(socket.id, socket)
|
|
47
|
+
}
|
|
44
48
|
} catch (e) {
|
|
45
49
|
console.error(e)
|
|
46
50
|
}
|
|
47
51
|
})
|
|
48
52
|
|
|
49
|
-
let tryConnect = 0
|
|
50
|
-
const tryConnectMax = 1
|
|
51
53
|
socket.on('connect_error', (err) => {
|
|
52
54
|
console.log(`event: connect_error | reason: ${err.message}`)
|
|
53
55
|
try {
|
|
54
56
|
if (isFunction(options.onError)) options.onError(err, socket)
|
|
57
|
+
|
|
55
58
|
if (tryConnect < tryConnectMax) {
|
|
56
59
|
socket.disconnect()
|
|
57
60
|
|
|
61
|
+
tryConnect++
|
|
62
|
+
console.log(tryConnect)
|
|
63
|
+
|
|
58
64
|
if (ENV === 'test' || ENV === 'development') {
|
|
59
65
|
console.log(
|
|
60
66
|
'Could not connect to %c' + primaryUrl + '%c, reconnecting to %c' + secondaryUrl,
|
|
@@ -69,7 +75,6 @@ export const connect = (key, options = {}) => {
|
|
|
69
75
|
} catch (e) {
|
|
70
76
|
console.error(e)
|
|
71
77
|
}
|
|
72
|
-
tryConnect++
|
|
73
78
|
})
|
|
74
79
|
|
|
75
80
|
socket.on('disconnect', (reason) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/socket",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.38",
|
|
4
4
|
"description": "Connect your app to Symbols editor",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"author": "symbo.ls",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"socket.io": "^4.5.2",
|
|
18
18
|
"socket.io-client": "^4.5.2"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "70f644a9f19b0a448ac52afac81d95c3b5441481"
|
|
21
21
|
}
|