|
|
|
1
|
+package com.qnbar.smc.service;
|
|
|
|
2
|
+
|
|
|
|
3
|
+import android.app.Service;
|
|
|
|
4
|
+import android.content.Context;
|
|
|
|
5
|
+import android.content.Intent;
|
|
|
|
6
|
+import android.os.Handler;
|
|
|
|
7
|
+import android.os.IBinder;
|
|
|
|
8
|
+import android.text.TextUtils;
|
|
|
|
9
|
+import android.util.Log;
|
|
|
|
10
|
+import android.widget.Toast;
|
|
|
|
11
|
+import com.gimi.common.cinema.model.MessageEvent;
|
|
|
|
12
|
+import com.gimi.common.cinema.model.RoomInfo;
|
|
|
|
13
|
+import com.gimi.common.cinema.utils.SystemUtils;
|
|
|
|
14
|
+import com.gimi.common.cinema.utils.Utils;
|
|
|
|
15
|
+import com.google.gson.Gson;
|
|
|
|
16
|
+import com.google.gson.JsonSyntaxException;
|
|
|
|
17
|
+import com.qnbar.smc.utils.LightOperationUtils;
|
|
|
|
18
|
+import com.xgimi.gimicinema.activity.QrCodeShowActivity;
|
|
|
|
19
|
+import com.xgimi.gimicinema.application.FangTangApplication;
|
|
|
|
20
|
+import com.xgimi.smartscreen.encrypt.AuthCode;
|
|
|
|
21
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
|
22
|
+
|
|
|
|
23
|
+import java.io.IOException;
|
|
|
|
24
|
+import java.io.InputStream;
|
|
|
|
25
|
+import java.io.OutputStream;
|
|
|
|
26
|
+import java.lang.ref.WeakReference;
|
|
|
|
27
|
+import java.net.Socket;
|
|
|
|
28
|
+import java.util.Arrays;
|
|
|
|
29
|
+
|
|
|
|
30
|
+import static com.qnbar.smc.service.SocketService.JUST_OPEN_DOOR;
|
|
|
|
31
|
+import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR;
|
|
|
|
32
|
+import static com.qnbar.smc.service.SocketService.USER_OPEN_DOOR_AND_GET_MOVIE;
|
|
|
|
33
|
+
|
|
|
|
34
|
+public class SocketService1 extends Service {
|
|
|
|
35
|
+ private static final String TAG = "BackService";
|
|
|
|
36
|
+ private static final long HEART_BEAT_RATE = 2 * 1000;
|
|
|
|
37
|
+
|
|
|
|
38
|
+ // public static final int USER_OPEN_DOOR_AND_GET_MOVIE = 1703;
|
|
|
|
39
|
+ /*
|
|
|
|
40
|
+ * 10001 //服务器发送了命令(带命令的返回消息),这个一般是服务器主动发消息的时候code为这个值
|
|
|
|
41
|
+ 10002 //连接(认证)失败
|
|
|
|
42
|
+ 10003 //还未注册连接就进行认证
|
|
|
|
43
|
+ 10004 //终端编号未传
|
|
|
|
44
|
+ 10005 //心跳异常,没有找到房间连接信息
|
|
|
|
45
|
+ 10006 //心跳异常,连接标识符不一致
|
|
|
|
46
|
+ 10007 //收到未知命令
|
|
|
|
47
|
+ 10008 //收到无法解析的消息
|
|
|
|
48
|
+ 10009 //已经认证过了,不允许再认证
|
|
|
|
49
|
+ 10010 //room_sn 已连接,不能再连接
|
|
|
|
50
|
+
|
|
|
|
51
|
+ 9997 //心跳成功
|
|
|
|
52
|
+ 9998 //请求认证被服务器接受了,服务器返回了认证码
|
|
|
|
53
|
+ 9999 //认证成功,可以开始心跳了
|
|
|
|
54
|
+ */
|
|
|
|
55
|
+ private static final int HEART_BEAT_SUCCESS = 9997;
|
|
|
|
56
|
+ private static final int RETURN_VERIFY_CODE = 9998;
|
|
|
|
57
|
+ private static final int VERIFY_SUCCESS = 9999;
|
|
|
|
58
|
+ private static final int SUCCESS_MESSAGE = 10000;
|
|
|
|
59
|
+ private static final int CONTAIN_MESSAGE = 10001;
|
|
|
|
60
|
+ private static final int AUTHENTICATION_FAILED = 10002; //连接(认证)失败
|
|
|
|
61
|
+ private static final int CONNECTION_BEFORE_AUTHENTICATION = 10003;//还未注册连接就进行认证
|
|
|
|
62
|
+ private static final int NOT_SEND_ROOM_SN = 10004;//终端编号未传
|
|
|
|
63
|
+ private static final int HEART_BEAR_ERROR = 10005; //心跳异常,没有找到房间连接信息
|
|
|
|
64
|
+ private static final int HEART_BEAR_ERROR_SYMBOL = 10006;//心跳异常,连接标识符不一致
|
|
|
|
65
|
+ private static final int OPEN_DOOR = 50001;//开门命令
|
|
|
|
66
|
+ private static final int CLEAN_OVER = 50002;//
|
|
|
|
67
|
+
|
|
|
|
68
|
+ private static final int ROOM_HAS_REGISTERED = 1001;
|
|
|
|
69
|
+ private static final int ROOM_NOT_EXIST_M = 1002;
|
|
|
|
70
|
+ private static final int HEAT_BEAT_RTN = 1003;
|
|
|
|
71
|
+
|
|
|
|
72
|
+ // online
|
|
|
|
73
|
+ public static final String SERVER_HOST_ONLINE = "conn.ft.qnbar.com";// "192.168.1.21";//
|
|
|
|
74
|
+ public static final int SERVER_PORT_ONLINE = 8899;
|
|
|
|
75
|
+
|
|
|
|
76
|
+ // develop
|
|
|
|
77
|
+ public static final String SERVER_HOST_DEVELOP = "10.10.4.6";// "192.168.1.21";//
|
|
|
|
78
|
+ public static final int SERVER_PORT_DEVELOP = 9501;
|
|
|
|
79
|
+ // test
|
|
|
|
80
|
+ public static final String SERVER_HOST = "10.10.4.6";// "192.168.1.21";//
|
|
|
|
81
|
+ public static final int SERVER_PORT = 8899;
|
|
|
|
82
|
+
|
|
|
|
83
|
+ private String serverHost = SERVER_HOST;
|
|
|
|
84
|
+ private int serverPort = SERVER_PORT;
|
|
|
|
85
|
+
|
|
|
|
86
|
+
|
|
|
|
87
|
+ public static final String END_SYMBOL = "\\r\\n\\r\\n";//心跳包内容
|
|
|
|
88
|
+ // public String testRoomSn = "R170413034374";
|
|
|
|
89
|
+ public String testRoomSn = "c";
|
|
|
|
90
|
+
|
|
|
|
91
|
+ private ReadThread mReadThread;
|
|
|
|
92
|
+ private Gson gson;
|
|
|
|
93
|
+
|
|
|
|
94
|
+ private WeakReference<Socket> mSocket;
|
|
|
|
95
|
+ // For heart Beat
|
|
|
|
96
|
+ private Handler mHandler = new Handler();
|
|
|
|
97
|
+ private Runnable heartBeatRunnable = new Runnable() {
|
|
|
|
98
|
+
|
|
|
|
99
|
+ @Override
|
|
|
|
100
|
+ public void run() {
|
|
|
|
101
|
+ Log.d(TAG, "heart beat");
|
|
|
|
102
|
+ mHandler.postDelayed(this, HEART_BEAT_RATE);
|
|
|
|
103
|
+ boolean isSuccess = sendMsg(new Gson().toJson(new SocketSendMsg().contractHeartBeatMsg(testRoomSn)) + END_SYMBOL);//就发送一个HEART_BEAT_STRING过去 如果发送失败,就重新初始化一个socket
|
|
|
|
104
|
+ if (!isSuccess) {
|
|
|
|
105
|
+ Log.d(TAG, "heart beat error restart");
|
|
|
|
106
|
+ mHandler.removeCallbacks(heartBeatRunnable);
|
|
|
|
107
|
+ mReadThread.release();
|
|
|
|
108
|
+ sendRegister = false;
|
|
|
|
109
|
+ releaseLastSocket(mSocket);
|
|
|
|
110
|
+ new InitSocketThread().start();
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ }
|
|
|
|
113
|
+ };
|
|
|
|
114
|
+
|
|
|
|
115
|
+ private long sendTime = 0L;
|
|
|
|
116
|
+ private Context context;
|
|
|
|
117
|
+
|
|
|
|
118
|
+ @Override
|
|
|
|
119
|
+ public IBinder onBind(Intent arg0) {
|
|
|
|
120
|
+ return null;
|
|
|
|
121
|
+ }
|
|
|
|
122
|
+
|
|
|
|
123
|
+ @Override
|
|
|
|
124
|
+ public void onCreate() {
|
|
|
|
125
|
+ super.onCreate();
|
|
|
|
126
|
+ gson = new Gson();
|
|
|
|
127
|
+ context = this;
|
|
|
|
128
|
+ }
|
|
|
|
129
|
+
|
|
|
|
130
|
+ @Override
|
|
|
|
131
|
+ public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
132
|
+ int ftTest = Utils.getInt(this, "ft-test", 0);
|
|
|
|
133
|
+ switch (ftTest) {
|
|
|
|
134
|
+ case 0:
|
|
|
|
135
|
+ serverHost = SERVER_HOST_ONLINE;
|
|
|
|
136
|
+ serverPort = SERVER_PORT_ONLINE;
|
|
|
|
137
|
+ break;
|
|
|
|
138
|
+ case 1:
|
|
|
|
139
|
+ serverHost = SERVER_HOST_DEVELOP;
|
|
|
|
140
|
+ serverPort = SERVER_PORT_DEVELOP;
|
|
|
|
141
|
+ break;
|
|
|
|
142
|
+ case 2:
|
|
|
|
143
|
+ serverHost = SERVER_HOST;
|
|
|
|
144
|
+ serverPort = SERVER_PORT;
|
|
|
|
145
|
+ break;
|
|
|
|
146
|
+ }
|
|
|
|
147
|
+
|
|
|
|
148
|
+ String roomInfoStr = Utils.getString(this, "room-info");
|
|
|
|
149
|
+ if (!TextUtils.isEmpty(roomInfoStr)) {
|
|
|
|
150
|
+ Log.d("room-info", "room info not null");
|
|
|
|
151
|
+ RoomInfo roomInfo = null;
|
|
|
|
152
|
+ try {
|
|
|
|
153
|
+ roomInfo = gson.fromJson(roomInfoStr, RoomInfo.class);
|
|
|
|
154
|
+ Log.d("room-info", "room info room_sn update");
|
|
|
|
155
|
+ testRoomSn = roomInfo.getData().getRoom_sn();
|
|
|
|
156
|
+ } catch (JsonSyntaxException e) {
|
|
|
|
157
|
+ Log.d("room-info", "room gson parse exception return");
|
|
|
|
158
|
+ Toast.makeText(this, "房间信息配置出错,请重新进入应用获取", Toast.LENGTH_SHORT).show();
|
|
|
|
159
|
+ e.printStackTrace();
|
|
|
|
160
|
+ return super.onStartCommand(intent, flags, startId);
|
|
|
|
161
|
+ }
|
|
|
|
162
|
+ } else {
|
|
|
|
163
|
+ Log.d("room-info", "room info not exist");
|
|
|
|
164
|
+ Toast.makeText(this, "没有获取到房间信息,请查看后台配置", Toast.LENGTH_SHORT).show();
|
|
|
|
165
|
+ return super.onStartCommand(intent, flags, startId);
|
|
|
|
166
|
+ }
|
|
|
|
167
|
+ new InitSocketThread().start();
|
|
|
|
168
|
+ Log.d(TAG, "socket service onCreate");
|
|
|
|
169
|
+ return super.onStartCommand(intent, flags, startId);
|
|
|
|
170
|
+ }
|
|
|
|
171
|
+
|
|
|
|
172
|
+ public boolean sendMsg(String msg) {
|
|
|
|
173
|
+ if (null == mSocket || null == mSocket.get()) {
|
|
|
|
174
|
+ return false;
|
|
|
|
175
|
+ }
|
|
|
|
176
|
+ Log.d(TAG, "send msg:" + msg);
|
|
|
|
177
|
+ Socket soc = mSocket.get();
|
|
|
|
178
|
+ try {
|
|
|
|
179
|
+ if (!soc.isClosed() && !soc.isOutputShutdown()) {
|
|
|
|
180
|
+ OutputStream os = soc.getOutputStream();
|
|
|
|
181
|
+ String message = msg;
|
|
|
|
182
|
+ os.write(message.getBytes());
|
|
|
|
183
|
+ os.flush();
|
|
|
|
184
|
+ sendTime = System.currentTimeMillis();//每次发送成数据,就改一下最后成功发送的时间,节省心跳间隔时间
|
|
|
|
185
|
+ } else {
|
|
|
|
186
|
+ return false;
|
|
|
|
187
|
+ }
|
|
|
|
188
|
+ } catch (IOException e) {
|
|
|
|
189
|
+ e.printStackTrace();
|
|
|
|
190
|
+ return false;
|
|
|
|
191
|
+ }
|
|
|
|
192
|
+ return true;
|
|
|
|
193
|
+ }
|
|
|
|
194
|
+
|
|
|
|
195
|
+ private void initSocket() throws IOException {//初始化Socket
|
|
|
|
196
|
+ Log.d(TAG, "serverHost:serverPort:" + serverHost + ":" + serverPort);
|
|
|
|
197
|
+ Socket so = new Socket(serverHost, serverPort);
|
|
|
|
198
|
+ mSocket = new WeakReference<Socket>(so);
|
|
|
|
199
|
+ mReadThread = new ReadThread(so);
|
|
|
|
200
|
+ mReadThread.start();
|
|
|
|
201
|
+ }
|
|
|
|
202
|
+
|
|
|
|
203
|
+
|
|
|
|
204
|
+ private void releaseLastSocket(WeakReference<Socket> mSocket) {
|
|
|
|
205
|
+ try {
|
|
|
|
206
|
+ if (null != mSocket) {
|
|
|
|
207
|
+ Socket sk = mSocket.get();
|
|
|
|
208
|
+ if (!sk.isClosed()) {
|
|
|
|
209
|
+ sk.close();
|
|
|
|
210
|
+ }
|
|
|
|
211
|
+ sk = null;
|
|
|
|
212
|
+ mSocket = null;
|
|
|
|
213
|
+ }
|
|
|
|
214
|
+ } catch (IOException e) {
|
|
|
|
215
|
+ e.printStackTrace();
|
|
|
|
216
|
+ }
|
|
|
|
217
|
+ }
|
|
|
|
218
|
+
|
|
|
|
219
|
+ class InitSocketThread extends Thread {
|
|
|
|
220
|
+ @Override
|
|
|
|
221
|
+ public void run() {
|
|
|
|
222
|
+ super.run();
|
|
|
|
223
|
+ try {
|
|
|
|
224
|
+ initSocket();
|
|
|
|
225
|
+ } catch (IOException e) {
|
|
|
|
226
|
+ e.printStackTrace();
|
|
|
|
227
|
+ Log.d(TAG, "init socket thread error,restart again after " + HEART_BEAT_RATE / 1000 + " seconds");
|
|
|
|
228
|
+ try {
|
|
|
|
229
|
+ Thread.sleep(HEART_BEAT_RATE);
|
|
|
|
230
|
+ } catch (InterruptedException e1) {
|
|
|
|
231
|
+ e1.printStackTrace();
|
|
|
|
232
|
+ }
|
|
|
|
233
|
+ this.run();
|
|
|
|
234
|
+ }
|
|
|
|
235
|
+ }
|
|
|
|
236
|
+ }
|
|
|
|
237
|
+
|
|
|
|
238
|
+ private String verifyMsg = "";
|
|
|
|
239
|
+
|
|
|
|
240
|
+ // Thread to read content from Socket
|
|
|
|
241
|
+ class ReadThread extends Thread {
|
|
|
|
242
|
+ private WeakReference<Socket> mWeakSocket;
|
|
|
|
243
|
+ private boolean isStart = true;
|
|
|
|
244
|
+
|
|
|
|
245
|
+ public ReadThread(Socket socket) {
|
|
|
|
246
|
+ mWeakSocket = new WeakReference<Socket>(socket);
|
|
|
|
247
|
+ }
|
|
|
|
248
|
+
|
|
|
|
249
|
+ public void release() {
|
|
|
|
250
|
+ isStart = false;
|
|
|
|
251
|
+ releaseLastSocket(mWeakSocket);
|
|
|
|
252
|
+ }
|
|
|
|
253
|
+
|
|
|
|
254
|
+ @Override
|
|
|
|
255
|
+ public void run() {
|
|
|
|
256
|
+ super.run();
|
|
|
|
257
|
+ Socket socket = mWeakSocket.get();
|
|
|
|
258
|
+ if (null != socket) {
|
|
|
|
259
|
+ try {
|
|
|
|
260
|
+ if (!sendRegister) {
|
|
|
|
261
|
+ Log.d(TAG, "send register mes");
|
|
|
|
262
|
+ SocketSendMsg ssm = new SocketSendMsg().contractRegisterMsg(testRoomSn);
|
|
|
|
263
|
+ String msg = gson.toJson(ssm) + END_SYMBOL;
|
|
|
|
264
|
+ sendMsg(msg);
|
|
|
|
265
|
+ Log.d(TAG, "" + msg);
|
|
|
|
266
|
+ sendRegister = true;
|
|
|
|
267
|
+ }
|
|
|
|
268
|
+ Log.d(TAG, "send register mes end");
|
|
|
|
269
|
+ InputStream is = socket.getInputStream();
|
|
|
|
270
|
+ byte[] buffer = new byte[1024 * 4];
|
|
|
|
271
|
+ int length = 0;
|
|
|
|
272
|
+ while (!socket.isClosed() && !socket.isInputShutdown()
|
|
|
|
273
|
+ && isStart && ((length = is.read(buffer)) != -1)) {
|
|
|
|
274
|
+ if (length > 0) {
|
|
|
|
275
|
+ String message = new String(Arrays.copyOf(buffer,
|
|
|
|
276
|
+ length)).trim();
|
|
|
|
277
|
+ Log.d(TAG, "recv msg:" + message);
|
|
|
|
278
|
+ try {
|
|
|
|
279
|
+ if (message.endsWith(END_SYMBOL)) {
|
|
|
|
280
|
+ message = message.replace(END_SYMBOL, "");
|
|
|
|
281
|
+ }
|
|
|
|
282
|
+ SocketResponse socketResponse = gson.fromJson(message, SocketResponse.class);
|
|
|
|
283
|
+ switch (socketResponse.getCode()) {
|
|
|
|
284
|
+ case SUCCESS_MESSAGE:
|
|
|
|
285
|
+ Log.d(TAG, "SUCCESS_MESSAGE");
|
|
|
|
286
|
+ break;
|
|
|
|
287
|
+ case VERIFY_SUCCESS:
|
|
|
|
288
|
+ Log.d(TAG, "VERIFY_SUCCESS");
|
|
|
|
289
|
+ mHandler.post(heartBeatRunnable);
|
|
|
|
290
|
+ Log.d(TAG, "verify success start heart beat");
|
|
|
|
291
|
+ break;
|
|
|
|
292
|
+ case HEART_BEAT_SUCCESS:
|
|
|
|
293
|
+ Log.d(TAG, "HEART_BEAT_SUCCESS");
|
|
|
|
294
|
+ break;
|
|
|
|
295
|
+ case RETURN_VERIFY_CODE:
|
|
|
|
296
|
+ Log.d(TAG, "RETURN_VERIFY_CODE");
|
|
|
|
297
|
+ if (!TextUtils.isEmpty(socketResponse.getData().getVerify())) {
|
|
|
|
298
|
+ verifyMsg = AuthCode.getDecodeStr(socketResponse.getData().getVerify());
|
|
|
|
299
|
+ SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg);
|
|
|
|
300
|
+ String msg = gson.toJson(ssm) + END_SYMBOL;
|
|
|
|
301
|
+ sendMsg(msg);
|
|
|
|
302
|
+ }
|
|
|
|
303
|
+ break;
|
|
|
|
304
|
+ case CONTAIN_MESSAGE:
|
|
|
|
305
|
+ Log.d(TAG, "CONTAIN_MESSAGE");
|
|
|
|
306
|
+ if (socketResponse.getData() != null) {
|
|
|
|
307
|
+ if (socketResponse.getCmd() == OPEN_DOOR) {
|
|
|
|
308
|
+ switch (socketResponse.getData().getUser()) {
|
|
|
|
309
|
+ //10用户,20管理员,默认值为0
|
|
|
|
310
|
+ case 10:
|
|
|
|
311
|
+ new SystemUtils().openFtLed(context.getApplicationContext());
|
|
|
|
312
|
+ if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
|
|
|
|
313
|
+ LightOperationUtils.open();
|
|
|
|
314
|
+ LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
|
|
|
|
315
|
+ }
|
|
|
|
316
|
+ sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when new user come in");
|
|
|
|
317
|
+ if (socketResponse.getData().getFirst() == 1) {
|
|
|
|
318
|
+ sendMessage(USER_OPEN_DOOR_AND_GET_MOVIE, "user first open the door");
|
|
|
|
319
|
+ } else {
|
|
|
|
320
|
+ sendMessage(USER_OPEN_DOOR, "user open the door");
|
|
|
|
321
|
+ }
|
|
|
|
322
|
+ break;
|
|
|
|
323
|
+ case 20:
|
|
|
|
324
|
+ if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) {
|
|
|
|
325
|
+ Log.d("LightOperationUtils", "admin open light");
|
|
|
|
326
|
+ LightOperationUtils.open();
|
|
|
|
327
|
+ LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50));
|
|
|
|
328
|
+ }
|
|
|
|
329
|
+ sendMessage(JUST_OPEN_DOOR, "administrator open the door");
|
|
|
|
330
|
+ break;
|
|
|
|
331
|
+ case 0:
|
|
|
|
332
|
+ sendMessage(JUST_OPEN_DOOR, "get zero none user or administrator open the door");
|
|
|
|
333
|
+ break;
|
|
|
|
334
|
+ default:
|
|
|
|
335
|
+ sendMessage(JUST_OPEN_DOOR, "none user or administrator open the door");
|
|
|
|
336
|
+ break;
|
|
|
|
337
|
+ }
|
|
|
|
338
|
+ } else if (socketResponse.getCmd() == CLEAN_OVER) {
|
|
|
|
339
|
+ Log.d("LightOperationUtils", "admin clean over close light");
|
|
|
|
340
|
+ LightOperationUtils.setLightValue(5);
|
|
|
|
341
|
+ LightOperationUtils.close();
|
|
|
|
342
|
+ new SystemUtils().closeFtLed(context.getApplicationContext());
|
|
|
|
343
|
+ sendMessage(QrCodeShowActivity.KILL_SELF, "finish the QR CODE activity when clean over");
|
|
|
|
344
|
+ }
|
|
|
|
345
|
+ }
|
|
|
|
346
|
+ break;
|
|
|
|
347
|
+ default:
|
|
|
|
348
|
+ Log.d(TAG, "default msg:" + socketResponse.toString());
|
|
|
|
349
|
+ }
|
|
|
|
350
|
+ } catch (JsonSyntaxException e) {
|
|
|
|
351
|
+ Log.d(TAG, message);
|
|
|
|
352
|
+ e.printStackTrace();
|
|
|
|
353
|
+ }
|
|
|
|
354
|
+ }
|
|
|
|
355
|
+ }
|
|
|
|
356
|
+ } catch (IOException e) {
|
|
|
|
357
|
+ e.printStackTrace();
|
|
|
|
358
|
+ }
|
|
|
|
359
|
+ }
|
|
|
|
360
|
+ }
|
|
|
|
361
|
+ }
|
|
|
|
362
|
+
|
|
|
|
363
|
+ private void sendMessage(int type, String msg) {
|
|
|
|
364
|
+ MessageEvent messageEvent = new MessageEvent();
|
|
|
|
365
|
+ messageEvent.setEventId(type);
|
|
|
|
366
|
+ messageEvent.setMessage(msg);
|
|
|
|
367
|
+ EventBus.getDefault().post(messageEvent);
|
|
|
|
368
|
+ }
|
|
|
|
369
|
+
|
|
|
|
370
|
+ boolean sendRegister = false;
|
|
|
|
371
|
+
|
|
|
|
372
|
+ @Override
|
|
|
|
373
|
+ public void onDestroy() {
|
|
|
|
374
|
+ Log.d(TAG, "socket service destroy");
|
|
|
|
375
|
+ super.onDestroy();
|
|
|
|
376
|
+ }
|
|
|
|
377
|
+} |