reconnect
This commit is contained in:
@@ -207,6 +207,11 @@ class ListenActivity : AppCompatActivity() {
|
||||
sendBroadcast(Intent(Constant.WEWORK_NOTIFY).apply {
|
||||
putExtra("type", "modify_channel")
|
||||
})
|
||||
runCatching {
|
||||
WeworkController.weworkService.reconnectWebSocket("modify_channel_direct")
|
||||
}.onFailure {
|
||||
LogUtils.w("重置后直连重连失败,等待广播触发: ${it.message}")
|
||||
}
|
||||
HttpUtil.getMyConfig(toast = false)
|
||||
MobclickAgent.onProfileSignIn(channel)
|
||||
}
|
||||
|
||||
@@ -50,9 +50,7 @@ class WeworkService : AccessibilityService() {
|
||||
registerReceiver(object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.getStringExtra("type") == "modify_channel") {
|
||||
LogUtils.e("更新channel")
|
||||
webSocketManager.close(1000, "modify_channel")
|
||||
initWebSocket()
|
||||
reconnectWebSocket("modify_channel")
|
||||
}
|
||||
}
|
||||
}, IntentFilter(Constant.WEWORK_NOTIFY))
|
||||
@@ -65,6 +63,14 @@ class WeworkService : AccessibilityService() {
|
||||
webSocketManager = WebSocketManager(url, listener)
|
||||
}
|
||||
|
||||
fun reconnectWebSocket(reason: String) {
|
||||
LogUtils.i("reconnectWebSocket: $reason")
|
||||
if (::webSocketManager.isInitialized) {
|
||||
webSocketManager.close(1000, reason)
|
||||
}
|
||||
initWebSocket()
|
||||
}
|
||||
|
||||
private fun initObserver() {
|
||||
if (!Constant.pushImage) return
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user