更新时间: 2021-03-08
# 重连说明
SDK 内已实现重连机制,在应用的整个生命周期内,开发者只需要调用一次 im.connect()
建立连接。当网络异常中断时,SDK 内部会尝试重新建立连接,业务层无需进行其他操作
当业务层使用 im.disconnect()
主动断开连接后,希望以断开前的身份重新进行连接时,可使用 im.reconnect()
进行重新连接:
im.reconnect().then(user => { console.log('重新链接成功, 链接用户 id 为: ', user.id); }).catch(error => { console.log('链接失败: ', error.code, error.msg); });
已复制
1
2
3
4
5
2
3
4
5