add[声望升级]

This commit is contained in:
Martin 2024-04-13 18:19:14 +08:00
parent 3f68e2a3aa
commit 0db8eefbe6
7 changed files with 218 additions and 257 deletions

View File

@ -898,6 +898,66 @@ public class UserBean implements Parcelable {
this.bubble = bubble; this.bubble = bubble;
} }
} }
@Override
public String toString() {
return "UserBean{" +
"id='" + id + '\'' +
", userNiceName='" + userNiceName + '\'' +
", avatar='" + avatar + '\'' +
", avatarThumb='" + avatarThumb + '\'' +
", sex=" + sex +
", signature='" + signature + '\'' +
", coin='" + coin + '\'' +
", gold='" + gold + '\'' +
", votes='" + votes + '\'' +
", consumption='" + consumption + '\'' +
", votestotal='" + votestotal + '\'' +
", province='" + province + '\'' +
", city='" + city + '\'' +
", location='" + location + '\'' +
", birthday='" + birthday + '\'' +
", level=" + level +
", levelAnchor=" + levelAnchor +
", lives=" + lives +
", follows=" + follows +
", fans=" + fans +
", vip=" + vip +
", liang=" + liang +
", car=" + car +
", medal_level=" + medal_level +
", medal_name='" + medal_name + '\'' +
", Dress=" + Dress +
", noble_id='" + noble_id + '\'' +
", yuanbao='" + yuanbao + '\'' +
", noble_name='" + noble_name + '\'' +
", islive='" + islive + '\'' +
", medal_no_display_src='" + medal_no_display_src + '\'' +
", hot_num='" + hot_num + '\'' +
", goodnum='" + goodnum + '\'' +
", fans_pic='" + fans_pic + '\'' +
", gifticon='" + gifticon + '\'' +
", department_name='" + department_name + '\'' +
", token_rong='" + token_rong + '\'' +
", noble_end_time='" + noble_end_time + '\'' +
", slide='" + slide + '\'' +
", users_type='" + users_type + '\'' +
", is_bind='" + is_bind + '\'' +
", mobile='" + mobile + '\'' +
", front_task='" + front_task + '\'' +
", is_admin='" + is_admin + '\'' +
", praise=" + praise +
", isHide=" + isHide +
", randomPk=" + randomPk +
", mRankPkImgUrl='" + mRankPkImgUrl + '\'' +
", user_info_complete=" + user_info_complete +
", fansLevel=" + fansLevel +
", typeMic=" + typeMic +
", isMicList=" + isMicList +
", isRequest=" + isRequest +
", fansEnterRoomUrl='" + fansEnterRoomUrl + '\'' +
'}';
}
} }

View File

@ -19,7 +19,6 @@ import io.agora.rtc2.ChannelMediaOptions;
import io.agora.rtc2.Constants; import io.agora.rtc2.Constants;
import io.agora.rtc2.IRtcEngineEventHandler; import io.agora.rtc2.IRtcEngineEventHandler;
import io.agora.rtc2.RtcConnection; import io.agora.rtc2.RtcConnection;
import io.agora.rtc2.RtcEngine;
import io.agora.rtc2.RtcEngineConfig; import io.agora.rtc2.RtcEngineConfig;
import io.agora.rtc2.RtcEngineEx; import io.agora.rtc2.RtcEngineEx;
import io.agora.rtc2.video.VideoCanvas; import io.agora.rtc2.video.VideoCanvas;
@ -55,7 +54,6 @@ public class SWManager extends BaseCacheManager {
/** /**
* 获取单列 * 获取单列
*
* @return * @return
*/ */
public static SWManager get() { public static SWManager get() {
@ -117,6 +115,10 @@ public class SWManager extends BaseCacheManager {
mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid)); mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
} }
/**
* 设置清晰度
* @param selectClarity
*/
public void setDimensions(int selectClarity) { public void setDimensions(int selectClarity) {
if (cfg != null && mRtcEngine != null) { if (cfg != null && mRtcEngine != null) {
switch (selectClarity) { switch (selectClarity) {
@ -135,9 +137,9 @@ public class SWManager extends BaseCacheManager {
} }
/** /**
* 创建 * 创建直播
*/ */
public void createRoom(String token, String channelName) { public void createChannel(String token, String channelName) {
ChannelMediaOptions options = new ChannelMediaOptions(); ChannelMediaOptions options = new ChannelMediaOptions();
// 设置角色 BROADCASTER (主播) AUDIENCE (观众) // 设置角色 BROADCASTER (主播) AUDIENCE (观众)
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
@ -145,23 +147,28 @@ public class SWManager extends BaseCacheManager {
mRtcEngine.joinChannel(token, channelName, uid, options); mRtcEngine.joinChannel(token, channelName, uid, options);
} }
public void updateMyVideoView(FrameLayout frameLayout, String channelName) { /**
mRtcEngine.setupRemoteVideoEx(null, null); * 更新主播视图
* @param frameLayout
RtcConnection rtcConnection = new RtcConnection(); */
rtcConnection.channelId = channelName; //自己频道名称 public void updateMyChannelView(FrameLayout frameLayout) {
rtcConnection.localUid = uid;//自己的ID mRtcEngine.setupLocalVideo(null);
SurfaceView surfaceView = new SurfaceView(mContext); SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true); surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView); frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid);
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); mRtcEngine.setupLocalVideo(videoCanvas);
} }
/**
public void joinExRoomEx(String strUid, String token,String toUid, String channelName) { * PK-加入对方主播直播间
* @param strUid
* @param token
* @param toUid
* @param channelName
*/
public void joinChannelEx(String strUid, String token, String toUid, String channelName) {
int tempUid; int tempUid;
if (StringUtil.isEmpty(strUid)) { if (StringUtil.isEmpty(strUid)) {
tempUid = 0; tempUid = 0;
@ -199,6 +206,11 @@ public class SWManager extends BaseCacheManager {
}); });
} }
@Override
public void onLeaveChannel(RtcStats stats) {
super.onLeaveChannel(stats);
}
@Override @Override
public void onError(int err) { public void onError(int err) {
super.onError(err); super.onError(err);
@ -207,6 +219,30 @@ public class SWManager extends BaseCacheManager {
}); });
} }
/**
* 退出对方直播间
* @param uid 自己的ID
* @param liveUid 对方直播间号
*/
public void exitChannelToUid(int uid, String liveUid){
RtcConnection rtcConnection = new RtcConnection();
rtcConnection.channelId = getChannelName(liveUid); //對方主播的頻道
rtcConnection.localUid = uid;//自己的ID
mRtcEngine.leaveChannelEx(rtcConnection);
}
//设置对方主播视图
private void setupRemoteVideo(int uid) {
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
pkContainer1.addView(surfaceView);
// SurfaceView 对象传入声网实时互动 SDK设置远端视图
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, uid));
}
public void setAnchorContainer(FrameLayout anchorContainer) {
this.anchorContainer = anchorContainer;
}
//远程监听 //远程监听
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() { private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
@Override @Override
@ -224,6 +260,7 @@ public class SWManager extends BaseCacheManager {
@Override @Override
public void onJoinChannelSuccess(String channel, int uid, int elapsed) { public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
super.onJoinChannelSuccess(channel, uid, elapsed); super.onJoinChannelSuccess(channel, uid, elapsed);
L.eSw("onJoinChannelSuccess 加入频道channel"+channel+" uid:"+uid+" elapsed:"+elapsed);
if (onRtcEngineListener != null) { if (onRtcEngineListener != null) {
onRtcEngineListener.onOpenSuccess(channel, uid); onRtcEngineListener.onOpenSuccess(channel, uid);
} }
@ -232,20 +269,29 @@ public class SWManager extends BaseCacheManager {
@Override @Override
public void onError(int err) { public void onError(int err) {
super.onError(err); super.onError(err);
L.eSw("onError 错误码:"+err);
ToastUtil.show("onError:" + err); ToastUtil.show("onError:" + err);
} }
@Override @Override
public void onTokenPrivilegeWillExpire(String token) { public void onTokenPrivilegeWillExpire(String token) {
super.onTokenPrivilegeWillExpire(token); super.onTokenPrivilegeWillExpire(token);
L.eSw("onTokenPrivilegeWillExpire_Token 即将失效");
refreshToken(); refreshToken();
} }
@Override @Override
public void onRequestToken() { public void onRequestToken() {
super.onRequestToken(); super.onRequestToken();
L.eSw("onRequestToken_Token失效");
refreshToken(); refreshToken();
} }
@Override
public void onLeaveChannel(RtcStats stats) {
super.onLeaveChannel(stats);
L.eSw("onLeaveChannel退出頻道");
}
}; };
private void refreshToken() { private void refreshToken() {
@ -255,6 +301,7 @@ public class SWManager extends BaseCacheManager {
if (mRtcEngine != null) { if (mRtcEngine != null) {
mRtcEngine.renewToken(data.getToken()); mRtcEngine.renewToken(data.getToken());
} }
L.eSw("refreshToken_重新获取Token成功");
} }
@Override @Override
@ -264,19 +311,6 @@ public class SWManager extends BaseCacheManager {
}); });
} }
//设置对方主播视图
private void setupRemoteVideo(int uid) {
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
pkContainer1.addView(surfaceView);
// SurfaceView 对象传入声网实时互动 SDK设置远端视图
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, uid));
}
public void setAnchorContainer(FrameLayout anchorContainer) {
this.anchorContainer = anchorContainer;
}
public interface onRtcEngineListener { public interface onRtcEngineListener {
void onOpenSuccess(String channel, int uid); void onOpenSuccess(String channel, int uid);
} }
@ -296,4 +330,7 @@ public class SWManager extends BaseCacheManager {
public void setLinkUserContainer(FrameLayout linkUserContainer) { public void setLinkUserContainer(FrameLayout linkUserContainer) {
this.linkUserContainer = linkUserContainer; this.linkUserContainer = linkUserContainer;
} }
public static String getChannelName(String liveUid) {
return CommonAppConfig.SWChannelPrefix + liveUid;
}
} }

View File

@ -1476,7 +1476,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
@Override @Override
public void onLinkMicToPk(String uid, String pkhead, String pkname) { public void onLinkMicToPk(String uid, String pkhead, String pkname) {
L.eSw("onLinkMicToPkonLinkMicToPkonLinkMicToPk");
} }
@Override @Override

View File

@ -887,7 +887,17 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
// TODO: 2024/4/12 视图渲染 // TODO: 2024/4/12 视图渲染
livePushRyViewHolder.setAnPkRtc(bean); livePushRyViewHolder.setAnPkRtc(bean);
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.UN_LEAVELIVE));
LiveRyAnchorActivity.isDRPK = 1;
LivePushRyViewHolder.btn_close.setVisibility(View.VISIBLE);
SocketRyLinkMicPkUtil.linkMicPkAccept(mSocketRyClient, mApplyUid, mApplyUrl, mApplyNmae);
EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UP_PK_TWO).setObject(mApplyUid));
onLinkMicPkStart(mApplyUid, 2);
}
});
/*IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, true, msg1.toString(), new IRCRTCResultCallback() { /*IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, true, msg1.toString(), new IRCRTCResultCallback() {
@Override @Override
@ -2294,6 +2304,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mPkUid = pkUid; mPkUid = pkUid;
mApplyUid = null; mApplyUid = null;
mApplyStream = null; mApplyStream = null;
if (mLiveLinkMicPkViewHolder == null) { if (mLiveLinkMicPkViewHolder == null) {
mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer); mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
mLiveLinkMicPkViewHolder.addToParent(); mLiveLinkMicPkViewHolder.addToParent();
@ -2301,7 +2312,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
if (mContext instanceof LiveAudienceActivity) { if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview(); ((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview();
} }
} }
mLiveLinkMicPkViewHolder.startAnim(); mLiveLinkMicPkViewHolder.startAnim();
EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(pkUid)); EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(pkUid));

View File

@ -204,10 +204,7 @@ public class SocketRyClient {
EventBus.getDefault().post("UsertoRY"); EventBus.getDefault().post("UsertoRY");
} else if (actions == 5) { } else if (actions == 5) {
JSONObject mic_data = map.getJSONObject("ct"); JSONObject mic_data = map.getJSONObject("ct");
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST).setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)));
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST)
.setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class))
);
MicedUserManager.get().upDataMicUserList(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)); MicedUserManager.get().upDataMicUserList(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class));
} else if (actions == 6) { } else if (actions == 6) {
if (WordUtil.isNewZh()) { if (WordUtil.isNewZh()) {
@ -216,9 +213,7 @@ public class SocketRyClient {
ToastUtil.show("The host has disabled the voice connection function"); ToastUtil.show("The host has disabled the voice connection function");
} }
EventBus.getDefault().post("endMic"); EventBus.getDefault().post("endMic");
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE).setObject(map.toJavaObject(LinkMicUserBean.class)));
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE)
.setObject(map.toJavaObject(LinkMicUserBean.class)));
} else if (actions == 8) { } else if (actions == 8) {
if (WordUtil.isNewZh()) { if (WordUtil.isNewZh()) {
ToastUtil.show("您已被移出多人語音連麥"); ToastUtil.show("您已被移出多人語音連麥");
@ -227,24 +222,16 @@ public class SocketRyClient {
} }
EventBus.getDefault().post("endMic"); EventBus.getDefault().post("endMic");
} else if (actions == 3) { } else if (actions == 3) {
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC).setObject(map.toJavaObject(LinkMicUserBean.class)));
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC)
.setObject(map.toJavaObject(LinkMicUserBean.class))
);
MicUserManager.get().upDataMicUser(map); MicUserManager.get().upDataMicUser(map);
} else if (actions == 7) {//取消连麦 } else if (actions == 7) {//取消连麦
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL));
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL)
);
MicUserManager.get().removeMiscUser(map); MicUserManager.get().removeMiscUser(map);
} }
break; break;
case Constants.UP_USER_LIST: case Constants.UP_USER_LIST:
mListener.onUpUserList(map.getJSONObject("ct")); mListener.onUpUserList(map.getJSONObject("ct"));
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_AUDIENCE_LIST).setObject(JSON.parseArray(map.getJSONObject("ct").getString("userlist"), LiveUserGiftBean.class)));
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_AUDIENCE_LIST)
.setObject(JSON.parseArray(map.getJSONObject("ct").getString("userlist"), LiveUserGiftBean.class))
);
break; break;
case Constants.CARD: case Constants.CARD:
// LiveLinkMicPresenter.setHD(map.getString("ct")); // LiveLinkMicPresenter.setHD(map.getString("ct"));
@ -263,9 +250,7 @@ public class SocketRyClient {
} else { } else {
if (!WordUtil.isNewZh() && map.getString("ct").contains("退出比賽") && map.getString("ct").contains("獲得勝利")) { if (!WordUtil.isNewZh() && map.getString("ct").contains("退出比賽") && map.getString("ct").contains("獲得勝利")) {
String ctTmp = map.getString("ct"); String ctTmp = map.getString("ct");
ctTmp = ctTmp.replace("由於", "Due to") ctTmp = ctTmp.replace("由於", "Due to").replace("退出比賽", "withdrawing from the competition").replace("獲得勝利", "won");
.replace("退出比賽", "withdrawing from the competition")
.replace("獲得勝利", "won");
map.put("ct", ctTmp); map.put("ct", ctTmp);
} }
systemChatMessage2(map.getString("ct")); systemChatMessage2(map.getString("ct"));
@ -333,16 +318,10 @@ public class SocketRyClient {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
} }
// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time")); // LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE).setPkScores(map.getJSONArray("userlist")).setUid(mLiveUid).setTime(map.getIntValue("drpk_time")));
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
.setPkScores(map.getJSONArray("userlist"))
.setUid(mLiveUid)
.setTime(map.getIntValue("drpk_time")));
if (livePushRyViewHolder == null) { if (livePushRyViewHolder == null) {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); // LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
);
} }
@ -352,14 +331,11 @@ public class SocketRyClient {
if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) { if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.topMargin = 0; params.topMargin = 0;
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
isDRPK = 0; isDRPK = 0;
} else { } else {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview(); // LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW));
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)
);
} }
//創建了多人房間 //創建了多人房間
@ -367,16 +343,12 @@ public class SocketRyClient {
/* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) { /* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
}*/ }*/
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
);
isDRPK = 1; isDRPK = 1;
} else if (action3 == 10) { } else if (action3 == 10) {
if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) { if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkview(); // LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
.setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW)
);
} }
} }
@ -413,39 +385,19 @@ public class SocketRyClient {
} else { } else {
boxTypeName = WordUtil.isNewZh() ? "PD盲盒" : "PD blind box"; boxTypeName = WordUtil.isNewZh() ? "PD盲盒" : "PD blind box";
} }
AllServerNotifyEvent allServerNotifyEvent AllServerNotifyEvent allServerNotifyEvent = new AllServerNotifyEvent().setBlindBoxId(map.getString("blind_box_id")).setBoxType(boxType).setBoxTypeName(boxTypeName).setDressName(WordUtil.isNewZh() ? map.getString("dress_name") : TextUtils.isEmpty(map.getString("dress_nameen")) ? map.getString("dress_name") : map.getString("dress_nameen")).setGiftNotification(map.getString("gift_notification")).setGiftName(WordUtil.isNewZh() ? mCt.getString("giftname") : mCt.getString("giftnameen")).setUserNiceName(map.getString("uname")).setGiftIcon(map.getString("gifticon")).setAnchorName(map.getString("ancherName")).setDisplaySrc(map.getString("display_src"));
= new AllServerNotifyEvent()
.setBlindBoxId(map.getString("blind_box_id"))
.setBoxType(boxType)
.setBoxTypeName(boxTypeName)
.setDressName(WordUtil.isNewZh() ? map.getString("dress_name") : TextUtils.isEmpty(map.getString("dress_nameen")) ? map.getString("dress_name") : map.getString("dress_nameen"))
.setGiftNotification(map.getString("gift_notification"))
.setGiftName(WordUtil.isNewZh() ? mCt.getString("giftname") : mCt.getString("giftnameen"))
.setUserNiceName(map.getString("uname"))
.setGiftIcon(map.getString("gifticon"))
.setAnchorName(map.getString("ancherName"))
.setDisplaySrc(map.getString("display_src"));
Log.e("AllServerNotifyEvent", allServerNotifyEvent.toString()); Log.e("AllServerNotifyEvent", allServerNotifyEvent.toString());
Log.e("AllServerNotifyEvent", map.toJSONString()); Log.e("AllServerNotifyEvent", map.toJSONString());
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX).setAllServerNotifyEvent(allServerNotifyEvent));
.setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
.setAllServerNotifyEvent(allServerNotifyEvent));
} else if (action2 == 89) {//红包 } else if (action2 == 89) {//红包
JSONObject mCt = map.getJSONObject("ct"); JSONObject mCt = map.getJSONObject("ct");
AllServerNotifyEvent allServerNotifyEvent AllServerNotifyEvent allServerNotifyEvent = new AllServerNotifyEvent().setUserNiceName(mCt.getString("user_nicename")).setGiftName(WordUtil.isNewZh() ? map.getString("giftname") : map.getString("giftname_en")).setGiftIcon(mCt.getString("gifticon")).setRedPacket(true);
= new AllServerNotifyEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX).setAllServerNotifyEvent(allServerNotifyEvent));
.setUserNiceName(mCt.getString("user_nicename"))
.setGiftName(WordUtil.isNewZh() ? map.getString("giftname") : map.getString("giftname_en"))
.setGiftIcon(mCt.getString("gifticon"))
.setRedPacket(true);
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX)
.setAllServerNotifyEvent(allServerNotifyEvent));
} else if (action2 == 90) { } else if (action2 == 90) {
NewAllServerNotifyGuardEvent notifyGuardEvent = GsonUtils.fromJson(map.toString(), NewAllServerNotifyGuardEvent.class); NewAllServerNotifyGuardEvent notifyGuardEvent = GsonUtils.fromJson(map.toString(), NewAllServerNotifyGuardEvent.class);
Bus.get().post(notifyGuardEvent); Bus.get().post(notifyGuardEvent);
buyGuardInSameRoom(map); buyGuardInSameRoom(map);
}else if (action2==91){ } else if (action2 == 91) {
AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent = GsonUtils.fromJson(map.toString(), AllServerNotifyFFGGGDJANEvent.class); AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent = GsonUtils.fromJson(map.toString(), AllServerNotifyFFGGGDJANEvent.class);
Bus.get().post(notifyFFGGGDJANEvent); Bus.get().post(notifyFFGGGDJANEvent);
} }
@ -473,12 +425,7 @@ public class SocketRyClient {
mListener.onAnchorInvalid(); mListener.onAnchorInvalid();
} }
//主播强制下播 //主播强制下播
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_END).setVotes(map.getString("votes")).setLength(map.getString("length")).setNums(map.getIntValue("nums")).setUname(map.getString("uname")));
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_END)
.setVotes(map.getString("votes"))
.setLength(map.getString("length"))
.setNums(map.getIntValue("nums"))
.setUname(map.getString("uname")));
break; break;
case Constants.SOCKET_CHANGE_LIVE://主播切换计时收费类型 case Constants.SOCKET_CHANGE_LIVE://主播切换计时收费类型
mListener.onChangeTimeCharge(map.getIntValue("type_val")); mListener.onChangeTimeCharge(map.getIntValue("type_val"));
@ -619,9 +566,7 @@ public class SocketRyClient {
List<MsgModel> msg = model.getMsg(); List<MsgModel> msg = model.getMsg();
if (msg.size() > 0) { if (msg.size() > 0) {
// EventBus.getDefault().post(msg.get(0)); // EventBus.getDefault().post(msg.get(0));
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.TRUMPET_NOTIFY).setMsgModel(msg.get(0)));
.setType(LiveAudienceEvent.LiveAudienceType.TRUMPET_NOTIFY)
.setMsgModel(msg.get(0)));
} }
break; break;
case Constants.RECOMMEND_CARD_NOTIFY://推荐卡消息通知 case Constants.RECOMMEND_CARD_NOTIFY://推荐卡消息通知
@ -629,9 +574,7 @@ public class SocketRyClient {
List<MsgModel> recommendCardNotifyMsg = recommendCardNotifyModel.getMsg(); List<MsgModel> recommendCardNotifyMsg = recommendCardNotifyModel.getMsg();
if (recommendCardNotifyMsg.size() > 0) { if (recommendCardNotifyMsg.size() > 0) {
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.RECOMMEND_CARD_NOTIFY).setMsgModel(recommendCardNotifyMsg.get(0)));
.setType(LiveAudienceEvent.LiveAudienceType.RECOMMEND_CARD_NOTIFY)
.setMsgModel(recommendCardNotifyMsg.get(0)));
} }
break; break;
case Constants.STAR_CHALLENGE_UPDATE://星级助力 case Constants.STAR_CHALLENGE_UPDATE://星级助力
@ -648,29 +591,21 @@ public class SocketRyClient {
case Constants.AI_AUTOMATIC_SPEECH_LIVE: case Constants.AI_AUTOMATIC_SPEECH_LIVE:
//{"name_color":"#f19ec2","ai_name":"助手小小P","content":"@1 ","user_name":"1","icon":"https://downs.yaoulive.com/xzs_tab.png","system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"} //{"name_color":"#f19ec2","ai_name":"助手小小P","content":"@1 ","user_name":"1","icon":"https://downs.yaoulive.com/xzs_tab.png","system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"}
AiAutomaticSpeechModel aiAutomaticSpeechModel = GsonUtils.fromJson(map.getString("ct"), AiAutomaticSpeechModel.class); AiAutomaticSpeechModel aiAutomaticSpeechModel = GsonUtils.fromJson(map.getString("ct"), AiAutomaticSpeechModel.class);
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.AI_AUTOMATIC_SPEECH).setAiAutomaticSpeechModel(aiAutomaticSpeechModel));
.setType(LiveAudienceEvent.LiveAudienceType.AI_AUTOMATIC_SPEECH)
.setAiAutomaticSpeechModel(aiAutomaticSpeechModel));
break; break;
case Constants.STAR_CHALLENGE_UPGRADE_NOTIFY: case Constants.STAR_CHALLENGE_UPGRADE_NOTIFY:
SocketModel starChallengeUpgradeNotify = GsonUtils.fromJson(socketMsg, SocketModel.class); SocketModel starChallengeUpgradeNotify = GsonUtils.fromJson(socketMsg, SocketModel.class);
List<MsgModel> starChallengeUpgradeNotifyMsg = starChallengeUpgradeNotify.getMsg(); List<MsgModel> starChallengeUpgradeNotifyMsg = starChallengeUpgradeNotify.getMsg();
if (starChallengeUpgradeNotifyMsg.size() > 0) { if (starChallengeUpgradeNotifyMsg.size() > 0) {
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.STAR_CHALLENGE_UPGRADE_NOTIFY).setMsgModel(starChallengeUpgradeNotifyMsg.get(0)));
.setType(LiveAudienceEvent.LiveAudienceType.STAR_CHALLENGE_UPGRADE_NOTIFY)
.setMsgModel(starChallengeUpgradeNotifyMsg.get(0)));
} }
break; break;
case Constants.LuckyAngel: case Constants.LuckyAngel:
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL).setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
.setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL)
.setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
break; break;
case Constants.Lucky100Check: case Constants.Lucky100Check:
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LUCKY_100_CHECK).setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
.setType(LiveAudienceEvent.LiveAudienceType.LUCKY_100_CHECK)
.setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
break; break;
case Constants.PK_RANK_UPDATE: case Constants.PK_RANK_UPDATE:
Log.i("PK排位", map.toString()); Log.i("PK排位", map.toString());
@ -680,117 +615,68 @@ public class SocketRyClient {
pkRankBean.setName(item.getString("new_rank_name")); pkRankBean.setName(item.getString("new_rank_name"));
pkRankBean.setImg(item.getString("new_rank_img")); pkRankBean.setImg(item.getString("new_rank_img"));
pkRankBean.setNewRankNameEn(item.getString("new_rank_name_en")); pkRankBean.setNewRankNameEn(item.getString("new_rank_name_en"));
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE).setObject(pkRankBean));
.setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE)
.setObject(pkRankBean));
break; break;
case Constants.CUSTOM_FULL_SERVICE_NOTIFY: case Constants.CUSTOM_FULL_SERVICE_NOTIFY:
Log.e("全服通知", map.toString()); Log.e("全服通知", map.toString());
CustomFullServiceNotifyEvent customFullServiceNotifyEvent = GsonUtils.fromJson(map.toString(), CustomFullServiceNotifyEvent.class); CustomFullServiceNotifyEvent customFullServiceNotifyEvent = GsonUtils.fromJson(map.toString(), CustomFullServiceNotifyEvent.class);
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.CUSTOM_FULL_SERVICE_NOTIFY).setCustomFullServiceNotifyEvent(customFullServiceNotifyEvent));
.setType(LiveAudienceEvent.LiveAudienceType.CUSTOM_FULL_SERVICE_NOTIFY)
.setCustomFullServiceNotifyEvent(customFullServiceNotifyEvent));
break; break;
case Constants.XYD_COMPLETE: case Constants.XYD_COMPLETE:
// xydComplete(map); // xydComplete(map);
XydCompleteModel xydCompleteModel = GsonUtils.fromJson(map.toString(), XydCompleteModel.class); XydCompleteModel xydCompleteModel = GsonUtils.fromJson(map.toString(), XydCompleteModel.class);
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.XYD_COMPLETE).setXydCompleteModel(xydCompleteModel).setLiveReceiveGiftBean(JSON.parseObject(map.toString(), LiveReceiveGiftBean.class)));
.setType(LiveAudienceEvent.LiveAudienceType.XYD_COMPLETE)
.setXydCompleteModel(xydCompleteModel)
.setLiveReceiveGiftBean(JSON.parseObject(map.toString(), LiveReceiveGiftBean.class)));
break; break;
case "GuardSpecialEffect": case "GuardSpecialEffect":
LiveReceiveGiftBean giftBean = JSON.parseObject(map.toString(), LiveReceiveGiftBean.class); LiveReceiveGiftBean giftBean = JSON.parseObject(map.toString(), LiveReceiveGiftBean.class);
giftBean.setMedal_name(map.getString("medal_name")); giftBean.setMedal_name(map.getString("medal_name"));
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GuardSpecialEffect).setLiveReceiveGiftBean(giftBean));
.setType(LiveAudienceEvent.LiveAudienceType.GuardSpecialEffect)
.setLiveReceiveGiftBean(giftBean));
break; break;
case Constants.WISH_LIST_PROGRESS: case Constants.WISH_LIST_PROGRESS:
StringBuffer conString = new StringBuffer(); StringBuffer conString = new StringBuffer();
conString.append(WordUtil.isNewZh() ? map.getString("msg") : map.getString("msg_en")); conString.append(WordUtil.isNewZh() ? map.getString("msg") : map.getString("msg_en"));
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST_PROGRESS).setWishListProgress(new WishModel().setWishlistProgress(map.getString("wishlist_progress")).setWishlistIcon(map.getString("wishlist_icon")).setWishlistName(map.getString("wishlist_name")).setWishlistNum(map.getString("wishlist_num")).setGiftType(map.getInteger("giftId")).setLuid(conString.toString())).setUname(map.getString("userName")).setLiveType(Integer.parseInt(map.getString("level"))));
.setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST_PROGRESS)
.setWishListProgress(new WishModel()
.setWishlistProgress(map.getString("wishlist_progress"))
.setWishlistIcon(map.getString("wishlist_icon"))
.setWishlistName(map.getString("wishlist_name"))
.setWishlistNum(map.getString("wishlist_num"))
.setGiftType(map.getInteger("giftId"))
.setLuid(conString.toString())).setUname(map.getString("userName")).setLiveType(Integer.parseInt(map.getString("level"))));
break; break;
case Constants.LIVE_VOTE_CREATE: case Constants.LIVE_VOTE_CREATE:
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.VOTE_CREATE).setObject(map));
.setType(LiveAudienceEvent.LiveAudienceType.VOTE_CREATE)
.setObject(map)
);
break; break;
case Constants.LIVE_VOTE_END: case Constants.LIVE_VOTE_END:
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.VOTE_END).setObject(map));
.setType(LiveAudienceEvent.LiveAudienceType.VOTE_END) EventBus.getDefault().post(new LiveAnchorEvent().setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END).setObject(map));
.setObject(map)
);
EventBus.getDefault().post(new LiveAnchorEvent()
.setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END)
.setObject(map)
);
break; break;
case Constants.LIVE_VOTE_UPDATE: case Constants.LIVE_VOTE_UPDATE:
//通知给观众 //通知给观众
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.VOTE_UPDATE).setObject(map));
.setType(LiveAudienceEvent.LiveAudienceType.VOTE_UPDATE)
.setObject(map)
);
//通知给主播 //通知给主播
EventBus.getDefault().post(new LiveAnchorEvent() EventBus.getDefault().post(new LiveAnchorEvent().setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE).setObject(map));
.setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE)
.setObject(map)
);
break; break;
case Constants.LIVE_PK_END: case Constants.LIVE_PK_END:
mListener.onEndPk(map.getLong("uid"), mListener.onEndPk(map.getLong("uid"), map.getLong("pkuid"), map.getLong("uid_score"), map.getLong("pkuid_score"), JSONObject.parseObject(map.getJSONObject("ct").getJSONObject("pk_top_users").toJSONString(), LivePKUserListBean.class));
map.getLong("pkuid"),
map.getLong("uid_score"),
map.getLong("pkuid_score"),
JSONObject.parseObject(map.getJSONObject("ct").getJSONObject("pk_top_users").toJSONString(), LivePKUserListBean.class)
);
break; break;
case Constants.RED_PACKET: case Constants.RED_PACKET:
RedPacketModel redPacketModel = GsonUtils.fromJson(map.toString(), RedPacketModel.class); RedPacketModel redPacketModel = GsonUtils.fromJson(map.toString(), RedPacketModel.class);
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET).setRedPacketModel(redPacketModel));
.setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET)
.setRedPacketModel(redPacketModel));
break; break;
case Constants.RED_PACKET_SUPER_JACKPOT: case Constants.RED_PACKET_SUPER_JACKPOT:
RedPacketInfoModel redPacketInfoModel = GsonUtils.fromJson(map.toString(), RedPacketInfoModel.class); RedPacketInfoModel redPacketInfoModel = GsonUtils.fromJson(map.toString(), RedPacketInfoModel.class);
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET_SUPER_JACKPOT).setRedPacketInfoModel(redPacketInfoModel));
.setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET_SUPER_JACKPOT)
.setRedPacketInfoModel(redPacketInfoModel));
break; break;
case "GiftWallIlluminate": case "GiftWallIlluminate":
Log.e("GiftWallIlluminate", map.toString()); Log.e("GiftWallIlluminate", map.toString());
Bus.get().post(new GiftWallIlluminateEvent() Bus.get().post(new GiftWallIlluminateEvent().setNewNumber(map.getInteger("new_number")).setMaxNumber(map.getInteger("max_number")));
.setNewNumber(map.getInteger("new_number"))
.setMaxNumber(map.getInteger("max_number")));
break; break;
case SOCKET_LIVE_MSG_TO_USER: case SOCKET_LIVE_MSG_TO_USER:
sendToUserMsg(map); sendToUserMsg(map);
break; break;
case "SudGameCreateRoom": case "SudGameCreateRoom":
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM).setAvatar(WordUtil.isNewZh() ? map.getString("sud_game_name") : map.getString("sud_game_name_en")).setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class)));
.setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM)
.setAvatar(WordUtil.isNewZh() ? map.getString("sud_game_name") : map.getString("sud_game_name_en"))
.setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class)));
break; break;
case "sendQuickGift": case "sendQuickGift":
SendQuickGiftModel sendQuickGiftModel = GsonUtils.fromJson(map.toString(), SendQuickGiftModel.class); SendQuickGiftModel sendQuickGiftModel = GsonUtils.fromJson(map.toString(), SendQuickGiftModel.class);
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(sendQuickGiftModel.getUserNicename()) stringBuffer.append(sendQuickGiftModel.getUserNicename()).append(WordUtil.isNewZh() ? " 送出了 " : " sent ").append(sendQuickGiftModel.getQuickGiftNumber()).append(WordUtil.isNewZh() ? " 個小PD " : " small pandas ");
.append(WordUtil.isNewZh() ? " 送出了 " : " sent ")
.append(sendQuickGiftModel.getQuickGiftNumber())
.append(WordUtil.isNewZh() ? " 個小PD " : " small pandas ");
systemChatMessage2(stringBuffer.toString()); systemChatMessage2(stringBuffer.toString());
Bus.get().post(new QuickGiftingEvent().setHotNum(sendQuickGiftModel.getHotNum())); Bus.get().post(new QuickGiftingEvent().setHotNum(sendQuickGiftModel.getHotNum()));
break; break;
@ -805,9 +691,7 @@ public class SocketRyClient {
pkRankBean.setRedVal(item.getString("uid_win_continuity")); pkRankBean.setRedVal(item.getString("uid_win_continuity"));
pkRankBean.setPkTopImgUrl(item.getString("pktt_img")); pkRankBean.setPkTopImgUrl(item.getString("pktt_img"));
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_START).setObject(pkRankBean));
.setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_START)
.setObject(pkRankBean));
break; break;
case "guardMaturityDateRemind": case "guardMaturityDateRemind":
GuardMaturityDateRemindModel maturityDateRemindModel = GsonUtils.fromJson(map.toString(), GuardMaturityDateRemindModel.class); GuardMaturityDateRemindModel maturityDateRemindModel = GsonUtils.fromJson(map.toString(), GuardMaturityDateRemindModel.class);
@ -1059,8 +943,7 @@ public class SocketRyClient {
FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level")); FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
u.setFansLevel(obj.getIntValue("medal_level")); u.setFansLevel(obj.getIntValue("medal_level"));
u.setFansEnterRoomUrl(obj.getString("medal_backgroup_thumb")); u.setFansEnterRoomUrl(obj.getString("medal_backgroup_thumb"));
if (fansMedalBean != null) if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
mListener.onEnterRoom(new LiveEnterRoomBean(u, chatBean)); mListener.onEnterRoom(new LiveEnterRoomBean(u, chatBean));
} }
} }
@ -1092,8 +975,7 @@ public class SocketRyClient {
//增加粉丝徽章信息 //增加粉丝徽章信息
chatBean.setMedalNmae(map.getString("medal_name")); chatBean.setMedalNmae(map.getString("medal_name"));
FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level")); FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
if (fansMedalBean != null) if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
//聊天列表显示 玩家名 1 礼物名 //聊天列表显示 玩家名 1 礼物名
if (CommonAppContext.lang.equals("chinese")) { if (CommonAppContext.lang.equals("chinese")) {
@ -1118,8 +1000,7 @@ public class SocketRyClient {
mListener.onSendGift(receiveGiftBean, null); mListener.onSendGift(receiveGiftBean, null);
} }
//同一个直播间时才刷新pk //同一个直播间时才刷新pk
if (mLiveUid.equals(map.getString("pkuid1")) || if (mLiveUid.equals(map.getString("pkuid1")) || mLiveUid.equals(map.getString("pkuid2"))) {
mLiveUid.equals(map.getString("pkuid2"))) {
mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean); mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
} }
} }
@ -1215,8 +1096,7 @@ public class SocketRyClient {
//增加粉丝徽章信息 //增加粉丝徽章信息
chatBean.setMedalNmae(map.getString("medal_name")); chatBean.setMedalNmae(map.getString("medal_name"));
FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level")); FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
if (fansMedalBean != null) if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
receiveGiftBean.setLiveChatBean(chatBean); receiveGiftBean.setLiveChatBean(chatBean);
@ -1244,11 +1124,7 @@ public class SocketRyClient {
} }
if (map.getIntValue("drpk_status") == 1) { if (map.getIntValue("drpk_status") == 1) {
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE).setPkScores(map.getJSONArray("userlist")).setUid(mLiveUid).setTime(0));
.setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE)
.setPkScores(map.getJSONArray("userlist"))
.setUid(mLiveUid)
.setTime(0));
// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0); // LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
} }
@ -1387,6 +1263,11 @@ public class SocketRyClient {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
mListener.onLinkMicToPk(map.getString("uid"), map.getString("pkhead"), map.getString("pkname")); mListener.onLinkMicToPk(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"));
mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
if (livePushRyViewHolder != null) {
UserBean userBean = new UserBean();
userBean.setId(map.getString("uid"));
livePushRyViewHolder.setAnPkRtc(userBean);
}
break; break;
case 3://对方主播拒绝PK的回调 case 3://对方主播拒绝PK的回调
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
@ -1399,30 +1280,18 @@ public class SocketRyClient {
break; break;
case 5://PK时候断开连麦的回调 case 5://PK时候断开连麦的回调
// if (rtcRoom != null) { // if (rtcRoom != null) {
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.DISCONNEXT_PK_TIME));
.setType(LiveAudienceEvent.LiveAudienceType.DISCONNEXT_PK_TIME)); //断开连麦
RCRTCEngine.getInstance().leaveOtherRoom(map.getString("pkuid"), true, new IRCRTCResultCallback() { HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout").execute(new HttpCallback() {
@Override @Override
public void onSuccess() { public void onSuccess(int code, String msg, String[] info) {
Log.e("ry", map.getString("pkuid") + "退出多人成功a as");
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", map.getString("pkuid") + "退asa出多人失败" + rtcErrorCode);
} }
}); });
//断开连麦
HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
}
});
// } // }
if (livePushRyViewHolder != null) {
livePushRyViewHolder.onLinkMicAnchorClose();
}
mListener.onLinkMicPkClose(1); mListener.onLinkMicPkClose(1);
if (RandomPkManager.getInstance().isRandomModel()) { if (RandomPkManager.getInstance().isRandomModel()) {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_DEFAULT); RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_DEFAULT);
@ -1436,8 +1305,10 @@ public class SocketRyClient {
break; break;
case 9://pk结束的回调 case 9://pk结束的回调
mListener.onLinkMicPkEnd(map.getString("win_uid")); mListener.onLinkMicPkEnd(map.getString("win_uid"));
EventBus.getDefault().post(new LiveAudienceEvent() EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_END));
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_END)); if (livePushRyViewHolder != null) {
livePushRyViewHolder.onLinkMicAnchorClose();
}
break; break;
case 10://系统发起PK回调 case 10://系统发起PK回调
JSONObject msg1 = new JSONObject(); JSONObject msg1 = new JSONObject();

View File

@ -120,6 +120,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
private boolean isPk = false; private boolean isPk = false;
private boolean isNeedOpenCamera = false; private boolean isNeedOpenCamera = false;
private SWManager swManager; private SWManager swManager;
private String pkUid1;
//修改上面主播的头像 //修改上面主播的头像
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
@ -515,31 +516,13 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
if (code == 0) { if (code == 0) {
JSONObject datas = JSONObject.parseObject(info[0]); JSONObject datas = JSONObject.parseObject(info[0]);
String pkUid = datas.getString("pkuid"); String pkUid = datas.getString("pkuid");
//退出副房间 //退出副房间
RCRTCEngine.getInstance().leaveOtherRoom(pkUid, true, new IRCRTCResultCallback() { // TODO: 2024/4/13 退出对方主播直播间
@Override SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),pkUid1);
public void onSuccess() { SWManager.get().updateMyChannelView((FrameLayout) mBigContainer);
Log.e("ry", "退出房间成功" + pkUid); EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
new Handler(Looper.getMainLooper()).post(new Runnable() { closeButtonGone();
public void run() {
mPreView1.removeAllViews();
mPreView1.setVisibility(View.GONE);
inputStreamList.clear();
inputStreamList1.clear();
changeToBig();
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
closeButtonGone();
}
});
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", pkUid + "退出房间s失败" + rtcErrorCode);
}
});
SocketSendBean seed_msg = new SocketSendBean() SocketSendBean seed_msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LINK_MIC_PK) .param("_method_", Constants.SOCKET_LINK_MIC_PK)
@ -772,7 +755,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
*/ */
private void initRtcEngine() { private void initRtcEngine() {
swManager = SWManager.get(); swManager = SWManager.get();
swManager.setAnchorContainer((FrameLayout) mLeftContainer); swManager.setAnchorContainer((FrameLayout) mBigContainer);
swManager.initRtcEngine((Activity) mContext, CommonAppConfig.getInstance().getUid()); swManager.initRtcEngine((Activity) mContext, CommonAppConfig.getInstance().getUid());
swManager.setOnRtcEngineListener(new SWManager.onRtcEngineListener() { swManager.setOnRtcEngineListener(new SWManager.onRtcEngineListener() {
@Override @Override
@ -788,14 +771,21 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
L.eSw("设置对方主播的视图setAnPkRtc" + u); L.eSw("设置对方主播的视图setAnPkRtc" + u);
//将自己的渲染视图设置到 leftContainer //将自己的渲染视图设置到 leftContainer
//swManager.updateMyVideoView((FrameLayout) mLeftContainer,SWAuManager.getChannelName(CommonAppConfig.getInstance().getUid())); swManager.updateMyChannelView((FrameLayout) mLeftContainer);
//清除 mBigContainer 中的渲染
mBigContainer.removeAllViews();
//设置对方主播的渲染视图 设置到 rightContainer //设置对方主播的渲染视图 设置到 rightContainer
swManager.setPkContainer1(mRightContainer); swManager.setPkContainer1(mRightContainer);
swManager.joinExRoomEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,u.getId(), SWAuManager.getChannelName(u.getId())); swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,u.getId(), SWAuManager.getChannelName(u.getId()));
} }
} }
public void onLinkMicAnchorClose(){
swManager.updateMyChannelView((FrameLayout) mBigContainer);
}
@Override @Override
public void changeToLeft() { public void changeToLeft() {
if (mPreView != null) { if (mPreView != null) {
@ -868,7 +858,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
public void startPush(String pushUrl) { public void startPush(String pushUrl) {
//开播成功创建频道 //开播成功创建频道
if (swManager != null) { if (swManager != null) {
swManager.createRoom(CommonAppConfig.SWToken, CommonAppConfig.getChannelName()); swManager.createChannel(CommonAppConfig.SWToken, CommonAppConfig.getChannelName());
} }
if (rcrtcLiveInfo != null) { if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback<String[]>() { rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback<String[]>() {
@ -1066,7 +1056,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
.param("ct", ct); .param("ct", ct);
seed_msg.create(); seed_msg.create();
HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2") HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2")
.params("GroupId", "g" + pkUid) .params("GroupId", "g" + pkUid)
.params("jsonstr", seed_msg.mResult.toString()) .params("jsonstr", seed_msg.mResult.toString())

View File

@ -94,10 +94,7 @@
<FrameLayout <FrameLayout
android:id="@+id/big_container" android:id="@+id/big_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"/>
</FrameLayout>
<LinearLayout <LinearLayout
android:id="@+id/layout_surface" android:id="@+id/layout_surface"
@ -158,20 +155,17 @@
android:id="@+id/pk_container" android:id="@+id/pk_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="270dp" android:layout_height="270dp"
android:background="@color/red"
android:layout_marginTop="130dp"> android:layout_marginTop="130dp">
<com.yunbao.live.custom.MyFrameLayout4 <com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/left_container" android:id="@+id/left_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/green"
android:layout_marginBottom="20dp" /> android:layout_marginBottom="20dp" />
<com.yunbao.live.custom.MyFrameLayout4 <com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/right_container" android:id="@+id/right_container"
android:layout_width="0dp" android:layout_width="0dp"
android:background="@color/gray1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="right" android:layout_gravity="right"
android:layout_marginBottom="20dp" /> android:layout_marginBottom="20dp" />