fix[修复-游戏房消息问题]

This commit is contained in:
Martin 2024-06-05 15:12:35 +08:00
parent 419e3a7ab5
commit 5baea0f156
5 changed files with 67 additions and 38 deletions

View File

@ -30,6 +30,7 @@ import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener; import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
import com.tencent.imsdk.v2.V2TIMUserInfo; import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.yunbao.common.http.Data;
import com.yunbao.common.manager.OpenAdManager; import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.BuildConfig; import com.yunbao.common.BuildConfig;
@ -65,6 +66,7 @@ import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import io.rong.imkit.config.RongConfigCenter; import io.rong.imkit.config.RongConfigCenter;
@ -216,6 +218,8 @@ public class AppContext extends CommonAppContext {
if (content.getContent().contains("_method_")) { if (content.getContent().contains("_method_")) {
msg.obj = content.getContent(); msg.obj = content.getContent();
//观众页面 //观众页面
String time = String.valueOf(new Date().getTime());
//声网 //声网
if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketSwClient.mSocketHandler.sendMessage(msg); SocketSwClient.mSocketHandler.sendMessage(msg);
@ -227,6 +231,10 @@ public class AppContext extends CommonAppContext {
String contentJson = ((TextMessage) message.getContent()).getContent(); String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson); Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
if (sudGameSocketImEvent.getMsg().isEmpty()) {
return false;
}
sudGameSocketImEvent.getMsg().get(0).setTime(time);
Bus.get().post(sudGameSocketImEvent); Bus.get().post(sudGameSocketImEvent);
} }
//主播页面 //主播页面
@ -245,6 +253,10 @@ public class AppContext extends CommonAppContext {
String contentJson = ((TextMessage) message.getContent()).getContent(); String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson); Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
if (sudGameSocketImEvent.getMsg().isEmpty()) {
return false;
}
sudGameSocketImEvent.getMsg().get(0).setTime(time);
Bus.get().post(sudGameSocketImEvent); Bus.get().post(sudGameSocketImEvent);
} }
//主播页面 //主播页面

View File

@ -53,6 +53,15 @@ public class SudGameSocketImEvent extends BaseModel {
private String method; private String method;
@SerializedName("equipment") @SerializedName("equipment")
private String equipment; private String equipment;
private String time;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getAction() { public String getAction() {
return action; return action;

View File

@ -433,6 +433,8 @@ public class GameSwMicManager {
}); });
} }
String lastTime = "";
/** /**
* 处理游戏房Im消息 * 处理游戏房Im消息
*/ */
@ -441,6 +443,11 @@ public class GameSwMicManager {
List<SudGameSocketImEvent.MsgDTO> msgDTOS = socketImModel.getMsg(); List<SudGameSocketImEvent.MsgDTO> msgDTOS = socketImModel.getMsg();
if (msgDTOS.isEmpty()) return; if (msgDTOS.isEmpty()) return;
SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0); SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
if(lastTime.equals(msgDTO.getTime())){
return;
}
lastTime = msgDTO.getTime();
//正常文字消息 //正常文字消息
if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) { if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) {
getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt())); getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt()));
@ -498,6 +505,7 @@ public class GameSwMicManager {
String contentJson = ((TextMessage) message.getContent()).getContent(); String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson); Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
sudGameSocketImEvent.getMsg().get(0).setTime("11");
processingMessage(sudGameSocketImEvent); processingMessage(sudGameSocketImEvent);
} }

View File

@ -407,6 +407,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
return this; return this;
} }
@Override
protected int getLayoutId() {
return R.layout.view_live_room;
}
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onUpdata(String str) { public void onUpdata(String str) {
if ("svga_new_user_gif".equals(str)) { if ("svga_new_user_gif".equals(str)) {
@ -713,11 +718,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
sudNameHandler.postDelayed(sudNameRunnable, 10000); sudNameHandler.postDelayed(sudNameRunnable, 10000);
} }
@Override
protected int getLayoutId() {
return R.layout.view_live_room;
}
private View sudGameMin; private View sudGameMin;
public void onShowHideEvent() { public void onShowHideEvent() {

View File

@ -691,7 +691,7 @@
android:layout_height="27dp" android:layout_height="27dp"
android:layout_below="@id/open_sidebar" android:layout_below="@id/open_sidebar"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginTop="16dp" android:layout_marginTop="20dp"
android:layout_marginRight="9dp" android:layout_marginRight="9dp"
android:background="@drawable/bg_live_other_ico" android:background="@drawable/bg_live_other_ico"
android:gravity="center"> android:gravity="center">