| | |
| | | package com.hdl.sdk.connect.protocol;
|
| | |
|
| | |
|
| | | import android.annotation.TargetApi;
|
| | | import android.os.Build;
|
| | | import android.util.Log;
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @RequiresApi(api = Build.VERSION_CODES.O)
|
| | |
|
| | | @Override
|
| | | protected synchronized LinkResponse decoder(Object msg) throws Exception {
|
| | | if (msg instanceof byte[]) {
|
| | |
| | | body = bodyBytes;
|
| | | } else {
|
| | | try {
|
| | | LogUtils.e("解密失败,数据内容是:\r\n" + Base64.getEncoder().encodeToString(body));
|
| | | LogUtils.e("解密失败,数据内容是:\r\n");
|
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
| | | LogUtils.e(Base64.getEncoder().encodeToString(body));
|
| | | else {
|
| | | LogUtils.e(new String(body, "utf-8"));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | String bodyString = new String(body, "utf-8");
|
| | | response.setData(bodyString);
|
| | | LogUtils.i( "接收到数据:" + response.getTopic() + "\r\n" + response.getData());
|
| | | //非正常数据,返回
|
| | | if (!(bodyString.startsWith("{") || bodyString.startsWith("["))) {
|
| | | continue;
|
| | | }
|
| | | response.setData(bodyString);
|
| | | LogUtils.i( "LinkMessageDecoder->decoder:" + response.getTopic() + "\r\n" + response.getData());
|
| | | //解析完成,topic发送一次
|
| | | EventDispatcher.getInstance().post(response.getTopic(), response);
|
| | | }
|