1:添加炼仙传说功能
2:修改混淆,
This commit is contained in:
@@ -35,6 +35,7 @@ public class MqttConnect {
|
||||
public static String qx_hour_ranking = "";
|
||||
|
||||
public static String qx_redpacket_arrive = "";//红包飘屏的主题
|
||||
public static String qx_xianxuan = "";//炼仙传说推送
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
String[] topic;
|
||||
int[] qos = {1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // 消息质量
|
||||
@@ -50,12 +51,14 @@ public class MqttConnect {
|
||||
update_app = "qx_xunlehui"; // 巡乐会飘屏
|
||||
qx_hour_ranking = "qx_hour_ranking";//小时榜飘屏
|
||||
qx_redpacket_arrive = "qx_redpacket_arrive"; //红包飘屏的主题
|
||||
qx_xianxuan = "qx_xianxuan"; //红包飘屏的主题
|
||||
|
||||
ArrayList<String> topicList = new ArrayList<>();
|
||||
topicList.add(shutdown);
|
||||
topicList.add(update_app);
|
||||
topicList.add(qx_hour_ranking);
|
||||
topicList.add(qx_redpacket_arrive);
|
||||
topicList.add(qx_xianxuan);
|
||||
topic = topicList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@@ -93,6 +96,7 @@ public class MqttConnect {
|
||||
sub(update_app);
|
||||
sub(qx_hour_ranking);
|
||||
sub(qx_redpacket_arrive);
|
||||
sub(qx_xianxuan);
|
||||
|
||||
// UI操作回到主线程
|
||||
ActivityUtils.getTopActivity().runOnUiThread(() -> uiTip("MQTT连接成功"));
|
||||
|
||||
@@ -6,9 +6,16 @@ import android.os.Looper;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xscm.moduleutil.base.RealTimeMessages;
|
||||
import com.xscm.moduleutil.base.SocketBean;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterEndBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.MonsterInfoBean;
|
||||
import com.xscm.moduleutil.bean.room.refining.OpenMonsterBean;
|
||||
import com.xscm.moduleutil.event.HourlyBean;
|
||||
import com.xscm.moduleutil.event.RedBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
@@ -59,6 +66,51 @@ public class MqttInitCallback implements MqttCallback {
|
||||
receiveQXHourRanking(topic, messageStr);
|
||||
} else if (topic.equals("qx_redpacket_arrive")) {
|
||||
receiveRed(topic, messageStr);
|
||||
} else if (topic.equals("qx_xianxuan")) {
|
||||
receiveXianxuanMessage(messageStr);
|
||||
}
|
||||
}
|
||||
|
||||
private void receiveXianxuanMessage(String messageStr) {
|
||||
try {
|
||||
JSONObject jsonObject = JSON.parseObject(messageStr);
|
||||
String message = jsonObject.getString("msg");
|
||||
// 将事件处理放到主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
processXianxuanMessage(message);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("MQTT", "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processXianxuanMessage(String message) {
|
||||
SocketBean dataList = GsonUtils.fromJson(message, SocketBean.class);
|
||||
switch (dataList.getCode()) {
|
||||
case 3031:
|
||||
RealTimeMessages<MonsterInfoBean> monsterInfo = GsonUtils.fromJson(
|
||||
message,
|
||||
new TypeToken<RealTimeMessages<MonsterInfoBean>>() {}.getType()
|
||||
);
|
||||
EventBus.getDefault().post(monsterInfo.data);
|
||||
break;
|
||||
case 3032:
|
||||
RealTimeMessages<OpenMonsterBean> openMonster =
|
||||
GsonUtils.fromJson(
|
||||
message,
|
||||
new TypeToken<RealTimeMessages<OpenMonsterBean>>() {}.getType()
|
||||
);
|
||||
EventBus.getDefault().post(openMonster.data);
|
||||
break;
|
||||
case 3033:
|
||||
RealTimeMessages<MonsterEndBean> monsterEndBean =
|
||||
GsonUtils.fromJson(
|
||||
message,
|
||||
new TypeToken<RealTimeMessages<MonsterEndBean>>() {}.getType()
|
||||
);
|
||||
EventBus.getDefault().post(monsterEndBean.data);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user