add[声望升级-自動PK,直接PK]

This commit is contained in:
Martin 2024-05-13 17:31:55 +08:00
parent 73414f3349
commit afef088555
8 changed files with 89 additions and 77 deletions

View File

@ -728,7 +728,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
@Override @Override
public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname, String isLadders) { public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname, String isLadders) {
if (mContext instanceof LiveAudienceActivity) return; if (mContext instanceof LiveAudienceActivity) return;
Log.e("ry", "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders); L.eSw( "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders);
if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
pr = new pkRunnable(pkUid, pkhead, pkname, isLadders); pr = new pkRunnable(pkUid, pkhead, pkname, isLadders);

View File

@ -193,7 +193,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
if (RandomPkManager.getInstance().isRankModel()) { if (RandomPkManager.getInstance().isRankModel()) {
msg1.put("is_ladders", "https://downs.yaoulive.com/rank_top_box.png"); msg1.put("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
} }
linkMicAnchorApply(pkUid, pkUid, msg1.toString()); linkMicAnchorApply(pkUid, pkUid, true);
} }
@Override @Override
@ -1203,7 +1203,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
*/ */
public void linkMicAnchorApply(String pkUid, String stream) { public void linkMicAnchorApply(String pkUid, String stream) {
JSONObject msg1 = buildLinkMicJSON(); JSONObject msg1 = buildLinkMicJSON();
linkMicAnchorApply(pkUid, stream, msg1.toString()); linkMicAnchorApply(pkUid, stream, false);
} }
public JSONObject buildLinkMicJSON() { public JSONObject buildLinkMicJSON() {
@ -1215,7 +1215,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
return msg1; return msg1;
} }
public void linkMicAnchorApply(final String pkUid, String stream, String extra) { public void linkMicAnchorApply(final String pkUid, String stream, boolean extra) {
LiveHttpUtil.livePkCheckLive(pkUid, stream, mStream, new HttpCallback() { LiveHttpUtil.livePkCheckLive(pkUid, stream, mStream, new HttpCallback() {
@Override @Override
@ -1224,71 +1224,46 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
JSONObject obj = JSON.parseObject(info[0]); JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) { if (obj != null) {
if (obj.getString("ispk").equals("0")) { if (obj.getString("ispk").equals("0")) {
final SocketSendBean msg1 = new SocketSendBean()
// TODO: 2024/4/11 发送IM消息 .param("_method_", SOCKET_LINK_MIC_PK)
final SocketSendBean msg1 = new SocketSendBean() .param("action", 1)
.param("_method_", SOCKET_LINK_MIC_PK) .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("action", 1) .param("pkuid", pkUid)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) .param("uid", CommonAppConfig.getInstance().getUid())
.param("pkuid", pkUid) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("uid", CommonAppConfig.getInstance().getUid()) .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); //判断是否是随机PK
msg1.create(); if(extra){
msg1.param("random_pk", "1");
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; msg1.param("msgtype","11");
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); if (RandomPkManager.getInstance().isRankModel()) {
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + pkUid, conversationType, messageContent); msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("tx", "发送成功");
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "发送失败" + errorCode.getMessage());
}
});
/*IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
// ToastUtil.show("邀请 " + pkUid + " 发送成功");
runOnUiThread(new Runnable() {
@Override
public void run() {
dismiss();
}
});
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dismiss();
}
});
//todo 安卓端状态码说明文档https://docs.rongcloud.cn/v4/views/rtc/call/code/android.html
Log.e("ry", rtcErrorCode + "aaaaaa" + CommonAppConfig.getInstance().getUid() + "VDSSSS" + pkUid);
if (WordUtil.isNewZh()) {
ToastUtil.show("邀请 " + pkUid + " 发送失败 " + rtcErrorCode);
} else {
ToastUtil.show("invite " + pkUid + " failed:" + rtcErrorCode);
} }
} }
});*/ msg1.create();
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + pkUid, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("tx", "发送成功");
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "发送失败" + errorCode.getMessage());
}
});
} else { } else {
ToastUtil.show("主播正在PK稍後再試"); ToastUtil.show("主播正在PK稍後再試");
if (RandomPkManager.getInstance().isRandomModel()) { if (RandomPkManager.getInstance().isRandomModel()) {

View File

@ -143,8 +143,7 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
} }
mOnItemClickListener.onItemClick(bean, -1); mOnItemClickListener.onItemClick(bean, -1);
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(), ((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString() false);
);
return; return;
} }
if (mDrPkNum <= 0) { if (mDrPkNum <= 0) {

View File

@ -632,8 +632,19 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
LiveRyAnchorActivity.isDRPK = 1; LiveRyAnchorActivity.isDRPK = 1;
/*---------------------------------------------------------------- */ /*---------------------------------------------------------------- */
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 2) //回复PK申请 2 final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", bean.getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); .param("action", 2) //回复PK申请 2
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("pkuid", bean.getId())
.param("uid", CommonAppConfig.getInstance().getUid())
.param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
if (RandomPkManager.getInstance().isRankModel()) {
L.eSw("排位赛");
msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
}
msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
msg1.create(); msg1.create();
System.out.println("PK回执 = " + msg1.toString()); System.out.println("PK回执 = " + msg1.toString());
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
@ -1071,6 +1082,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
.param("pkuid", CommonAppConfig.getInstance().getUid()) .param("pkuid", CommonAppConfig.getInstance().getUid())
.param("msgtype", 2) .param("msgtype", 2)
.param("uid", drPkbeans.get(i).getId()) .param("uid", drPkbeans.get(i).getId())
.param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create(); msg1.create();

View File

@ -66,7 +66,8 @@ public class SocketLinkMicPkUtil {
.param("uid", CommonAppConfig.getInstance().getUid()) .param("uid", CommonAppConfig.getInstance().getUid())
.param("pkuid", CommonAppConfig.getInstance().getUid()) .param("pkuid", CommonAppConfig.getInstance().getUid())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("name", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg.create(); msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() { V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback<V2TIMMessage>() {
@Override @Override

View File

@ -2,6 +2,7 @@ package com.yunbao.live.socket;
import static com.blankj.utilcode.util.SnackbarUtils.dismiss; import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
import static com.blankj.utilcode.util.ViewUtils.runOnUiThread; import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER; import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER;
import static com.yunbao.common.Constants.isAnchor; import static com.yunbao.common.Constants.isAnchor;
@ -29,6 +30,7 @@ import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.FansModel; import com.yunbao.common.bean.FansModel;
import com.yunbao.common.bean.GuardMaturityDateRemindModel; import com.yunbao.common.bean.GuardMaturityDateRemindModel;
import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.PkRankBean;
@ -49,6 +51,7 @@ import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.event.SendMoneyLongEndEvent; import com.yunbao.common.event.SendMoneyLongEndEvent;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.MicUserManager; import com.yunbao.common.manager.MicUserManager;
import com.yunbao.common.manager.MicedUserManager; import com.yunbao.common.manager.MicedUserManager;
@ -1294,13 +1297,13 @@ public class SocketRyClient {
case 2://收到对方主播PK回调 case 2://收到对方主播PK回调
L.eSw("收到对方主播PK回调"); L.eSw("收到对方主播PK回调");
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("uhead"), map.getString("uhead"));
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("uhead"), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
if (livePushRyViewHolder != null) { if (livePushRyViewHolder != null) {
UserBean userBean = new UserBean(); UserBean userBean = new UserBean();
userBean.setId(map.getString("uid")); userBean.setId(map.getString("uid"));
userBean.setAvatar(map.getString("pkhead")); userBean.setAvatar(map.getString("uhead"));
userBean.setUserNiceName(map.getString("pkname")); userBean.setUserNiceName(map.getString("uname"));
livePushRyViewHolder.setAnPkRtc(userBean); livePushRyViewHolder.setAnPkRtc(userBean);
} }
break; break;
@ -1347,12 +1350,13 @@ public class SocketRyClient {
} }
break; break;
case 10://系统发起PK回调 case 10://系统发起PK回调
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 2) .param("action", 2)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("pkuid", CommonAppConfig.getInstance().getUid()) .param("pkuid", CommonAppConfig.getInstance().getUid())
.param("msgtype", 2) .param("msgtype", 2)
.param("uid", CommonAppConfig.getInstance().getUid()) .param("uid", CommonAppConfig.getInstance().getUid())
.param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg1.create(); msg1.create();
@ -1377,6 +1381,28 @@ public class SocketRyClient {
} }
}); });
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
LiveNetManager.get(mContext).getLiveInfo(map.getString("uid"), new com.yunbao.common.http.base.HttpCallback<LiveInfoModel>() {
@Override
public void onSuccess(LiveInfoModel data) {
mListener.onLinkMicToPk(map.getString("uid"), data.getAvatar(), map.getString("uhead"));
mListener.onLinkMicPkStart(map.getString("uid"), data.getAvatar(), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
if (livePushRyViewHolder != null) {
UserBean userBean = new UserBean();
userBean.setId(map.getString("uid"));
userBean.setAvatar(data.getAvatar());
userBean.setUserNiceName(map.getString("uname"));
livePushRyViewHolder.setAnPkRtc(userBean);
}
}
@Override
public void onError(String error) {
}
}
);
/*JSONObject msg1 = new JSONObject(); /*JSONObject msg1 = new JSONObject();
msg1.put("type", "autoLivePK"); msg1.put("type", "autoLivePK");

View File

@ -301,7 +301,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
JSONObject map = JSONObject.parseObject(extra); JSONObject map = JSONObject.parseObject(extra);
userBean1.setId(map.getString("uid")); userBean1.setId(map.getString("uid"));
userBean1.setUserNiceName(map.getString("pkname")); userBean1.setUserNiceName(map.getString("pkname"));
userBean1.setAvatar(map.getString("pkhead")); userBean1.setAvatar(map.getString("uhead"));
} else { } else {
userBean1.setId(inviterRoomId); userBean1.setId(inviterRoomId);
userBean1.setUserNiceName("null"); userBean1.setUserNiceName("null");

View File

@ -2575,7 +2575,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
initPkRankView(bean); initPkRankView(bean);
if (!StringUtil.isEmpty(bean.getClickUrl())) { if (!StringUtil.isEmpty(bean.getClickUrl())) {
pkRankVf.setOnClickListener(v -> { pkRankVf.setOnClickListener(v -> {
MobclickAgent.onEvent(mContext, "live_room_sky", "天梯赛按钮"); MobclickAgent.onEvent(mContext, "live_room_sky", "天梯赛按钮");
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();