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.V2TIMSimpleMsgListener;
import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.yunbao.common.http.Data;
import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.BuildConfig;
@ -65,6 +66,7 @@ import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import io.rong.imkit.config.RongConfigCenter;
@ -123,7 +125,7 @@ public class AppContext extends CommonAppContext {
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
activities.add(new WeakReference<>(activity));
if(activity instanceof LoginActivity){
if (activity instanceof LoginActivity) {
AppManager.getInstance().clear();
}
CrashSaveBean.getInstance().setActivitySize(activities);
@ -205,7 +207,7 @@ public class AppContext extends CommonAppContext {
RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {
@Override
public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) {
Log.e("wewe", message.getConversationType() + "112121 "+message.getContent());
Log.e("wewe", message.getConversationType() + "112121 " + message.getContent());
MessageIMManager.get(sInstance).getSystemForRongcloud(message);
//融云直播间聊天
Message msg = Message.obtain();
@ -216,41 +218,51 @@ public class AppContext extends CommonAppContext {
if (content.getContent().contains("_method_")) {
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()))) {
SocketSwClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
sendStartAnchorLive(map);
} else if (message.getTargetId().contains("v")) {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.sendMessage(msg);
if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketSwClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
sendStartAnchorLive(map);
} else if (message.getTargetId().contains("v")) {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
if (sudGameSocketImEvent.getMsg().isEmpty()) {
return false;
}
sudGameSocketImEvent.getMsg().get(0).setTime(time);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.sendMessage(msg);
}
//融云
if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
sendStartAnchorLive(map);
} else if (message.getTargetId().contains("v")) {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
sendStartAnchorLive(map);
} else if (message.getTargetId().contains("v")) {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
if (sudGameSocketImEvent.getMsg().isEmpty()) {
return false;
}
sudGameSocketImEvent.getMsg().get(0).setTime(time);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
} else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息
EventBus.getDefault().post(message);
}

View File

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

View File

@ -433,6 +433,8 @@ public class GameSwMicManager {
});
}
String lastTime = "";
/**
* 处理游戏房Im消息
*/
@ -441,6 +443,11 @@ public class GameSwMicManager {
List<SudGameSocketImEvent.MsgDTO> msgDTOS = socketImModel.getMsg();
if (msgDTOS.isEmpty()) return;
SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
if(lastTime.equals(msgDTO.getTime())){
return;
}
lastTime = msgDTO.getTime();
//正常文字消息
if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) {
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();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
sudGameSocketImEvent.getMsg().get(0).setTime("11");
processingMessage(sudGameSocketImEvent);
}

View File

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

View File

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