@aochuang/client-sdk 1.0.326 → 1.0.327
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/package.json
CHANGED
|
@@ -33,21 +33,20 @@ export default class ClietChatSocket {
|
|
|
33
33
|
// 执行消息前回调
|
|
34
34
|
this.beforeFireCallback = options.beforeFireCallback
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
|
|
37
|
+
sendMessage (message, beforeCallback) {
|
|
38
|
+
return this.socket.sendMessage(message, (data) => {
|
|
39
|
+
let ps = Promise.resolve()
|
|
40
|
+
// 如果发送消息的时候,连接是断开或者失败的,重新连接一次,主要是防止用户发送消息的时候网络断开了,提示socket已关闭,体验不好,程序静默来处理
|
|
41
|
+
if (this.socket.connectStatus === Socket.CONNECT_STATUS_ENUM.Close || this.socket.connectStatus === Socket.CONNECT_STATUS_ENUM.Error) {
|
|
42
|
+
ps = this.socket.reconnect()
|
|
43
|
+
}
|
|
44
|
+
return ps.finally(() => {
|
|
45
|
+
if (beforeCallback) {
|
|
46
|
+
return beforeCallback(data)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
49
|
})
|
|
50
|
-
return this.socket.sendMessage(message)
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
connect () {
|