|
@@ -14,13 +14,17 @@ import com.xhly.corelib.bean.AppInfo
|
14
|
14
|
import com.xhly.corelib.eventbus.UIEvent
|
15
|
15
|
import com.xhly.corelib.network.RetrofitService
|
16
|
16
|
import com.xhly.corelib.utils.AppUtils
|
|
17
|
+import com.xhly.corelib.utils.GsonUtils
|
17
|
18
|
import com.xhly.corelib.utils.LogShow
|
|
19
|
+import com.xhly.corelib.utils.MD5Utils
|
18
|
20
|
import com.xhly.corelib.utils.SharedPreferencesUtils
|
19
|
21
|
import com.xhly.manageapp.ManageApplication
|
20
|
22
|
import com.xhly.manageapp.bean.LogAppStartBean
|
21
|
23
|
import com.xhly.manageapp.bean.LogdOperateBean
|
22
|
24
|
import com.xhly.manageapp.network.LogService
|
|
25
|
+import com.xhly.websocket.bean.WebSocketData
|
23
|
26
|
import com.xhly.websocket.service.LongConnService
|
|
27
|
+import com.xhly.websocket.service.WebSocketHelper
|
24
|
28
|
import com.xhly.websocket.utils.SocketPushUtils.dealPushMessage
|
25
|
29
|
import kotlinx.coroutines.CoroutineScope
|
26
|
30
|
import kotlinx.coroutines.MainScope
|
|
@@ -29,6 +33,7 @@ import kotlinx.coroutines.launch
|
29
|
33
|
import org.greenrobot.eventbus.EventBus
|
30
|
34
|
import org.greenrobot.eventbus.Subscribe
|
31
|
35
|
import org.greenrobot.eventbus.ThreadMode
|
|
36
|
+import java.util.UUID
|
32
|
37
|
|
33
|
38
|
open class AppSocketService : LongConnService() {
|
34
|
39
|
var CHANNEL_ID = "1"
|
|
@@ -64,6 +69,7 @@ open class AppSocketService : LongConnService() {
|
64
|
69
|
appList = AppUtils.GetAppList(this) as ArrayList<AppInfo>
|
65
|
70
|
}
|
66
|
71
|
|
|
72
|
+
|
67
|
73
|
override fun processTextMessage(text: String) {
|
68
|
74
|
//Log.v("websocket收到的消息", text);
|
69
|
75
|
dealPushMessage(text)
|
|
@@ -72,6 +78,15 @@ open class AppSocketService : LongConnService() {
|
72
|
78
|
override fun onConnectedSuccess() {
|
73
|
79
|
super.onConnectedSuccess()
|
74
|
80
|
UIEvent(Const.UPDATE_CONNECTED_SUCCESS).post()
|
|
81
|
+ val webData=WebSocketData()
|
|
82
|
+ webData.code=1002
|
|
83
|
+ webData.mid=UUID.randomUUID().toString()
|
|
84
|
+ val currentTimeSeconds = System.currentTimeMillis() / 1000
|
|
85
|
+ webData.timeunix=currentTimeSeconds
|
|
86
|
+ webData.fid=1
|
|
87
|
+ val jsMD5 = MD5Utils.getJsMD5(webData.code.toString()+"_"+webData.mid+"_"+webData.timeunix.toString())
|
|
88
|
+ webData.sign=MD5Utils.getJsMD5(jsMD5)
|
|
89
|
+ WebSocketHelper.getInstance().sendSocketString(GsonUtils.parseClassToJson(webData))
|
75
|
90
|
}
|
76
|
91
|
|
77
|
92
|
@Subscribe(threadMode = ThreadMode.MAIN)
|