diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java index 73c90d4a7..f5a4b5a78 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java @@ -1,16 +1,25 @@ package com.yunbao.common.manager.imrongcloud; +import android.text.TextUtils; import android.util.Log; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.yunbao.common.CommonAppContext; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.SudGameChatImModel; +import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.event.SudGameSocketImEvent; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.WordUtil; import java.util.ArrayList; import java.util.List; +import cn.rongcloud.rtc.api.RCRTCRemoteUser; +import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; +import cn.rongcloud.rtc.api.stream.RCRTCInputStream; +import cn.rongcloud.rtc.base.RTCErrorCode; import io.rong.imlib.IRongCallback; import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; @@ -41,6 +50,42 @@ public class GameSwMicManager { mMeetingCallback = null; } + /** + * 处理游戏房Im消息 + */ + public void processingMessage(SudGameSocketImEvent socketImModel) { + + List msgDTOS = socketImModel.getMsg(); + if (msgDTOS.isEmpty()) return; + SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0); + + //正常文字消息 + if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) { + getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt())); + } else if (TextUtils.equals(msgDTO.getMethod(), "welcomMessage")) { + // 欢迎(用户名)进入房间 Welcome (username) to the room + + StringBuffer stringBuffer = new StringBuffer(); + if (WordUtil.isNewZh()) { + stringBuffer.append("歡迎 ").append(msgDTO.getCt()).append(" 進入房間"); + } else { + stringBuffer.append("Welcome ").append(msgDTO.getCt()).append(" to enter the room"); + } + + getView().insertItem(new SudGameChatImModel().setWelcomMessage(true).setNickname(msgDTO.getCt()).setTextMessage(stringBuffer.toString())); + } else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) { + List personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken>() { + }.getType()); + getView().refreshSudGameUserList(personList); + //refreshStreams(personList); + } + } + + public void refreshStreams(String userID, boolean mute, int position) { + getView().onSubscribeSuccess(userID, mute, position); + } + + private void sendChatMessage(String textMessage, String method) { IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo(); SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent(); @@ -111,6 +156,8 @@ public class GameSwMicManager { void onUnPublishStreamsSuccess(); void onSubscribeSuccess(String userID, boolean mute, int position); + void insertItem(SudGameChatImModel sudGameChatImModel); + void refreshSudGameUserList(List personList); } } diff --git a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java index ae5ad483c..1a6519e70 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java @@ -747,6 +747,20 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameSocketImEvent(SudGameSocketImEvent event) { + gameMicManager.processingMessage(event); + } + @Override + public void insertItem(SudGameChatImModel sudGameChatImModel) { + mLiveChatAdapter.insertItem(sudGameChatImModel); + } + + @Override + public void refreshSudGameUserList(List personList) { + sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser); + } + @Override public void onUnPublishStreamsSuccess() { runOnUiThread(new Runnable() { @@ -771,10 +785,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M } - @Subscribe(threadMode = ThreadMode.MAIN) - public void onSudGameSocketImEvent(SudGameSocketImEvent event) { - } - @Subscribe(threadMode = ThreadMode.MAIN) public void onSudGameUserModel(SudGameUserModel model) { if (model.isNullUser()) {