add[声望升级-AB面]

This commit is contained in:
Martin 2024-05-18 18:27:38 +08:00
parent 6a4ac35203
commit 0b218157d2
12 changed files with 1052 additions and 115 deletions

View File

@ -50,6 +50,7 @@ import com.yunbao.common.utils.GoogleUtils;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.live.socket.SocketReceiveBean;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.views.PortraitLiveManager;
@ -198,7 +199,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");
Log.e("wewe", message.getConversationType() + "112121 "+message.getContent());
MessageIMManager.get(sInstance).getSystemForRongcloud(message);
//融云直播间聊天
Message msg = Message.obtain();
@ -209,23 +210,42 @@ public class AppContext extends CommonAppContext {
if (content.getContent().contains("_method_")) {
msg.obj = content.getContent();
//观众页面
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(SocketRyClient.mSocketHandler!=null){
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 (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.sendMessage(msg);
if(SocketSwClient.mSocketHandler!=null){
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);
}
}
} else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息
EventBus.getDefault().post(message);
}

View File

@ -88,6 +88,7 @@ import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LoadDian9TuUtil;
import com.yunbao.live.views.AbsLiveViewHolder;
@ -166,7 +167,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
protected List<LiveUserGiftBean> mAudienceList = new ArrayList<>();
protected LiveMicAnchorDialogFragment.OnMicListener micListener = null;
public boolean isSw;
public static boolean isSw;
@Override
protected void main() {
@ -241,13 +242,22 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
// if (isRy == false) {
// SocketChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
// } else {
SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
if(isSw){
SocketSwChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
}else{
SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
}
// }
}
// if (isRy == false) {
// SocketChatUtil.getFakeFans(mLiveUid);
// } else {
SocketRyChatUtil.getFakeFans(mLiveUid);
if(isSw){
SocketSwChatUtil.getFakeFans(mLiveUid);
}else{
SocketRyChatUtil.getFakeFans(mLiveUid);
}
// }
}
}
@ -1004,7 +1014,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
onCoinChanged(coin);
}
String[] data = new String[]{obj.getString("barragetoken")};
SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents, obj.getIntValue("level_fans"));
if(isSw){
SocketSwChatUtil.sendDanmuMessage(mLiveUid, contents, obj.getIntValue("level_fans"));
}else{
SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents, obj.getIntValue("level_fans"));
}
} else if (code == 1001) {
DialogUitl.showSimpleDialog(mContext, msg, new DialogUitl.SimpleCallback2() {
@Override
@ -1038,15 +1052,44 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
}
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
SocketRyChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
if(isSw){
SocketSwChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
}else{
SocketRyChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
}
}
/**
* 系统 消息 融云
*/
public static void sendSystemMessageSw(String content) {
if(isSw){
SocketSwChatUtil.sendSystemMessage(mLiveUid, content);
}else{
SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
}
}
/**
* 系统 消息 声网
*/
public static void sendSystemMessageRy(String content) {
if(isSw){
SocketSwChatUtil.sendSystemMessage(mLiveUid, content);
}else{
SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
}
}
/**
* 系统 消息
*/
public static void sendSystemMessage(String content) {
SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
public void sendSystemMessage(String content) {
if(isSw){
SocketSwChatUtil.sendSystemMessage(mLiveUid, content);
}else{
SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
}
}
@ -1055,7 +1098,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/
public void sendGiftMessage(LiveGiftBean giftBean, String giftToken, String ancherName, String by) {
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by);
if(isSw){
SocketSwChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by);
}else{
SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by);
}
}
@ -1063,28 +1110,44 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 主播或管理员踢人
*/
public void kickUser(String toUid, String toName) {
SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName);
if(isSw){
SocketSwChatUtil.sendKickMessage(mLiveUid, toUid, toName);
}else{
SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName);
}
}
/**
* 禁言
*/
public void setShutUp(String toUid, String toName, int type) {
SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type);
if(isSw){
SocketSwChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type);
}else{
SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type);
}
}
/**
* 期限禁言
*/
public void setShutUp(String toUid, String toName, int type, int time) {
SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type, time);
if(isSw){
SocketSwChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type, time);
}else{
SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type, time);
}
}
/**
* 设置或取消管理员消息
*/
public void sendSetAdminMessage(int action, String toUid, String toName) {
SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName);
if(isSw){
SocketSwChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName);
}else{
SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName);
}
}
@ -1092,14 +1155,24 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 超管关闭直播间
*/
public void superCloseRoom() {
SocketRyChatUtil.superCloseRoom(mLiveUid);
if(isSw){
SocketSwChatUtil.superCloseRoom(mLiveUid);
}else{
SocketRyChatUtil.superCloseRoom(mLiveUid);
}
}
/**
* 更新主播映票数
*/
public void sendUpdateVotesMessage(int deltaVal) {
SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal);
if(isSw){
SocketSwChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal);
}else{
SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal);
}
}
@ -1107,12 +1180,21 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 发送购买守护成功消息
*/
public void sendBuyGuardMessage(String votes, int guardNum, int guardType) {
SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType);
if(isSw){
SocketSwChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType);
}else{
SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType);
}
}
public void sendBuyGuardMessage2(String votes, int guardNum, int guardType, String ancherName, String liveId) {
if (guardType != 1) {
SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId);
if(isSw){
SocketSwChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId);
}else{
SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId);
}
}
}
@ -1120,7 +1202,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 发送发红包成功消息
*/
public void sendRedPackMessage() {
SocketRyChatUtil.sendRedPackMessage(mLiveUid);
if(isSw){
SocketSwChatUtil.sendRedPackMessage(mLiveUid);
}else{
SocketRyChatUtil.sendRedPackMessage(mLiveUid);
}
}
@ -1707,7 +1793,12 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
micListener = fragment.getMicListener();
fragment.setMicQueueList(mMicQueueList);
fragment.setAudienceList(mAudienceList);
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
if(isSw){
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
}else{
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
}
}
/**

View File

@ -471,7 +471,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
mLiveReadyViewHolder = null;
if (mLiveRoomViewHolder == null) {
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager());
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager(),false);
mLiveRoomViewHolder.addToParent();
mLiveRoomViewHolder.subscribeActivityLifeCycle();
mLiveRoomViewHolder.setLiveInfo(mLiveUid, mStream, obj.getIntValue("userlist_time") * 1000);

View File

@ -104,10 +104,8 @@ import com.yunbao.live.music.LiveMusicDialogFragment;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.views.LiveEndViewHolder;
import com.yunbao.live.views.LiveMusicViewHolder;
@ -554,7 +552,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(BitmapUtil.getInstance().convertMirror(resource), rect);
sendSystemMessage(mContext.getString(R.string.live_anchor_leave));
sendSystemMessageRy(mContext.getString(R.string.live_anchor_leave));
}
@Override
@ -567,7 +565,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
leave_img.setVisibility(View.GONE);
// 清除水印
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect);
sendSystemMessage(mContext.getString(R.string.live_anchor_come_back));
sendSystemMessageRy(mContext.getString(R.string.live_anchor_come_back));
}
HttpClient.getInstance().get("Live.isLeave", "Live.isLeave")
@ -788,7 +786,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
mLiveReadyViewHolder = null;
if (mLiveRoomViewHolder == null) {
mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager());
mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager(),isSw);
mLiveRoomViewHolder.setManager(manager);
mLiveRoomViewHolder.addToParent();
mLiveRoomViewHolder.subscribeActivityLifeCycle();
@ -974,7 +972,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
JSONObject obj = JSON.parseObject(info[0]);
JSONObject datas = obj.getJSONObject("data");
try {
SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid, mSocketSwClient);
SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid);
} catch (Exception e) {
e.printStackTrace();
}
@ -1060,8 +1058,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
mLivePushViewHolder = null;
mLiveLinkMicPresenter = null;
//断开socket
if (mSocketSwClient != null) {
mSocketSwClient.disConnect();
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
}
super.release();
}
@ -1891,8 +1889,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
@Override
public void onSuccess(Message message) {
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}

View File

@ -101,7 +101,7 @@ import com.yunbao.live.music.LiveMusicDialogFragment;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.views.LiveEndViewHolder;
@ -536,7 +536,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(BitmapUtil.getInstance().convertMirror(resource), rect);
sendSystemMessage(mContext.getString(R.string.live_anchor_leave));
sendSystemMessageSw(mContext.getString(R.string.live_anchor_leave));
}
@Override
@ -549,7 +549,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
leave_img.setVisibility(View.GONE);
// 清除水印
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect);
sendSystemMessage(mContext.getString(R.string.live_anchor_come_back));
sendSystemMessageSw(mContext.getString(R.string.live_anchor_come_back));
}
HttpClient.getInstance().get("Live.isLeave", "Live.isLeave")
@ -770,7 +770,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
}
mLiveReadyViewHolder = null;
if (mLiveRoomViewHolder == null) {
mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager());
mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager(),isSw);
mLiveRoomViewHolder.setManager(manager);
mLiveRoomViewHolder.addToParent();
mLiveRoomViewHolder.subscribeActivityLifeCycle();
@ -956,7 +956,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
JSONObject obj = JSON.parseObject(info[0]);
JSONObject datas = obj.getJSONObject("data");
try {
SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid, mSocketSwClient);
SocketSwChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -47,6 +47,8 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveReportActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.bean.ImpressBean;
import com.yunbao.live.custom.MyTextView;
import com.yunbao.live.utils.LiveTextRender;
@ -551,8 +553,7 @@ public class LiveOldUserDialogFragment extends AbsDialogFragment implements View
mFollowImage.setImageDrawable(mFollowing ? mFollowDrawable : mUnFollowDrawable);
}
if (isAttention == 1 && mLiveUid.equals(mToUid)) {//关注了主播
((LiveActivity) mContext).sendSystemMessage(
CommonAppConfig.getInstance().getUserBean().getUserNiceName() + mContext.getString(R.string.live_follow_anchor));
((LiveActivity) mContext).sendSystemMessage(CommonAppConfig.getInstance().getUserBean().getUserNiceName() + mContext.getString(R.string.live_follow_anchor));
}
}
};

View File

@ -34,7 +34,7 @@ import io.rong.message.TextMessage;
public class SocketRyChatUtil {
//关闭直播
public static void closeLive(final String votes, final String length, final String nums, final String mLiveUid, SocketSwClient client) {
public static void closeLive(final String votes, final String length, final String nums, final String mLiveUid) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_END)
@ -64,8 +64,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null)
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
@ -128,8 +128,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
LiveNetManager.get(CommonAppContext.sInstance)
.addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@ -214,8 +214,8 @@ public class SocketRyChatUtil {
}
}
});
if (SocketSwClient.mSocketHandler != null)
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
@ -263,8 +263,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -400,8 +400,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -470,8 +470,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -517,8 +517,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -554,8 +554,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -597,8 +597,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null)
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
@ -634,8 +634,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -674,8 +674,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@ -778,8 +778,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}

View File

@ -0,0 +1,793 @@
package com.yunbao.live.socket;
import android.util.Log;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import org.greenrobot.eventbus.EventBus;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
/**
* Created by cxf on 2018/10/9.
* 直播间发言
*/
public class SocketSwChatUtil {
//关闭直播
public static void closeLive(final String votes, final String length, final String nums, final String mLiveUid) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_END)
.param("action", 18)
.param("msgtype", 1)
.param("equipment", "app")
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("length", length)
.param("votes", votes)
.param("nums", nums)
.param("roomnum", u.getId())
.param("ct", "直播关闭");
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 发言
*/
public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType, String atUserID, String atUserName) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
IMLoginModel model = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
if (u == null) {
return;
}
final SocketSendBean msg =
new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_MSG)
.param("action", 0)
.param("msgtype", 2)
.param("usertype", userType)
.param("isAnchor", isAnchor ? 1 : 0)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("bubble", u.getDress().getBubble())
.param("medal_honor", u.getMedal_no_display_src())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("uid", u.getId())
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType())
.param("medal_name", u.getMedalName())
.param("medal_level", model.getMedalLevel())
.param("good_num", u.getGoodnum())
.param("ct", content)
.param("noble_id", String.valueOf(model.getNobleId()))
.param("contentColor", String.valueOf(model.getContentColor()))
.param("startColor", String.valueOf(model.getStartColor()))
.param("endColor", String.valueOf(model.getEndColor()))
.param("atUserName", String.valueOf(atUserName))
.param("atUserID", String.valueOf(atUserID));
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
LiveNetManager.get(CommonAppContext.sInstance)
.addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "aaa" + errorCode.toString());
if (errorCode.code == 23408) {
ToastUtil.show(WordUtil.isNewZh() ? "您已被禁言" : "You have been banned");
} else {
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" + errorCode.code : "I'm sorry! An error occurred" + errorCode.code);
}
}
});
}
/**
* 点亮
*/
public static void sendLightMessage(final String mLiveUid, int heart, int guardType) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_MSG)
.param("action", 0)
.param("msgtype", 2)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("medal_honor", u.getMedal_no_display_src())
.param("heart", heart)
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType())
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("good_num", u.getGoodnum())
.param("ct", WordUtil.getNewString(R.string.live_lighted));
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
LiveHttpUtil.sendZAN(mLiveUid + "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
EventBus.getDefault().post("stop_svga_new_user_double");
}
});
LiveHttpUtil.setFrontTask("illumine", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
EventBus.getDefault().post("stop_svga_new_user_double1");
}
}
});
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 发送弹幕消息
*/
public static void sendDanmuMessage(String mLiveUid, String danmuToken) {
sendDanmuMessage(mLiveUid, danmuToken, 0);
}
public static void sendDanmuMessage(String mLiveUid, String danmuToken, int fansLevel) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_BARRAGE)
.param("action", 7)
.param("msgtype", 1)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("uhead", u.getAvatar())
.param("fansLevel", fansLevel)
.param("ct", danmuToken);
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "aaa" + errorCode.toString());
if (errorCode.code == 23408) {
ToastUtil.show(WordUtil.isNewZh() ? "您已被禁言" : "You have been banned");
} else {
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
}
}
});
}
/**
* 发送礼物消息
*/
public static void sendGiftMessage(int giftType, String giftToken, String liveUid, int guard_type, String by) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_GIFT)
.param("action", 0)
.param("msgtype", 1)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("uhead", u.getAvatar())
.param("evensend", giftType)
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("ct", giftToken)
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("guard_type", guard_type + "")
.param("medal_honor", u.getMedal_no_display_src())
.param("good_num", u.getGoodnum())
.param("roomnum", liveUid);
msg.create();
LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("tag", "禮物im");
}
});
}
/**
* 发送礼物消息 增加主播名字
*/
public static void sendGiftMessage(int giftType, String giftToken, String liveUid, String ancherName, int guard_type, String by) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SEND_GIFT)
.param("action", 0)
.param("msgtype", 1)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("uhead", u.getAvatar())
.param("evensend", giftType)
.param("liangname", u.getGoodName())
.param("vip_type", u.getVip().getType())
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("ct", giftToken)
.param("ancherName", ancherName)
.param("medal_name", u.getMedalName())
.param("medal_level", u.getMedalLevel())
.param("guard_type", guard_type + "")
.param("medal_honor", u.getMedal_no_display_src())
.param("good_num", u.getGoodnum())
.param("roomnum", liveUid);
msg.create();
LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("tag", "禮物im");
}
});
}
/**
* 主播或管理员 踢人
*/
public static void sendKickMessage(String mLiveUid, String toUid, String toName) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_KICK)
.param("action", 2)
.param("msgtype", 4)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("touid", toUid)
.param("toname", toName)
.param("ct", toName + "被踢出房間(Kicked out of the room)");
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 主播或管理员 禁言
*/
public static void sendShutUpMessage(String mLiveUid, String toUid, String toName, int type) {
sendShutUpMessage(mLiveUid, toUid, toName, type, 0);
}
/**
* 主播或管理员 禁言
*
* @param time 禁言时间 1~60
*/
public static void sendShutUpMessage(String mLiveUid, String toUid, String toName, int type, int time) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
String ct = "";
switch (type) {
case 0:
ct = "被永久禁言(Forbidden forever)";
break;
case 1:
ct = "被本場禁言(Forbidden by this scene)";
break;
case 2:
ct = String.format("被禁言%s分鐘", time + "") + "(" + String.format("Forbidden by %s min", time + "") + ")";
break;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SHUT_UP)
.param("action", 1)
.param("msgtype", 4)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("touid", toUid)
.param("toname", toName)
.param("time", time)
.param("ct", toName + ct);
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 设置或取消管理员消息
*/
public static void sendSetAdminMessage(String mLiveUid, int action, String toUid, String toName) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
String s = action == 1 ? "被設為管理員(Set as Administrator)" : "被取消管理員(Cancelled administrator)";
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SET_ADMIN)
.param("action", action)
.param("msgtype", 1)
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("touid", toUid)
.param("toname", toName)
.param("ct", toName + " " + s);
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 超管关闭直播间
*/
public static void superCloseRoom(String mLiveUid) {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_STOP_LIVE)
.param("action", 19)
.param("msgtype", 1)
.param("ct", "");
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 发系统消息
*/
public static void sendSystemMessage(String mLiveUid, String content) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_SYSTEM)
.param("action", 13)
.param("msgtype", 4)
.param("level", u.getLevel())
.param("uname", u.getUserNiceName())
.param("uid", u.getId())
.param("ct", content);
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 获取僵尸粉
*/
public static void getFakeFans(String mLiveUid) {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_FAKE_FANS)
.param("action", "")
.param("msgtype", "");
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 更新主播映票数
*/
public static void sendUpdateVotesMessage(String mLiveUid, int votes, int first) {
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_UPDATE_VOTES)
.param("action", 1)
.param("msgtype", 26)
.param("votes", votes)
.param("uid", CommonAppConfig.getInstance().getUid())
.param("isfirst", first)
.param("ct", "");
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 更新主播映票数
*/
public static void sendUpdateVotesMessage(String mLiveUid, int votes) {
sendUpdateVotesMessage(mLiveUid, votes, 0);
}
/**
* 发送购买守护成功消息
*/
public static void sendBuyGuardMessage(String mLiveUid, String votes, int guardNum, int guardType) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_BUY_GUARD)
.param("action", 0)
.param("msgtype", 0)
.param("uid", u.getId())
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("uname", u.getUserNiceName())
.param("uhead", u.getAvatar())
.param("votestotal", votes)
.param("guard_nums", guardNum)
.param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType());
msg.create();
}
public static void sendBuyGuardMessage2(String mLiveUid, String votes, int guardNum,
int guardType, String ancherName, String liveId) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_BUY_GUARD)
.param("action", 0)
.param("msgtype", 0)
.param("uid", u.getId())
.param("uname", u.getUserNiceName())
.param("uhead", u.getAvatar())
.param("votestotal", votes)
.param("guard_nums", guardNum)
.param("ancherName", ancherName)
.param("liveuid", liveId)
.param("bubble", u.getDress().getBubble())
.param("medal", u.getDress().getMedal())
.param("medal_new", u.getDress().getMedal_new())
.param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType());
msg.create();
}
/**
* 发送发红包成功消息
*/
public static void sendRedPackMessage(String mLiveUid) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_RED_PACK)
.param("action", 0)
.param("msgtype", 0)
.param("uid", u.getId())
.param("uname", u.getUserNiceName())
.param("ct", CommonAppContext.sInstance.getBaseContext().getString(R.string.red_pack_22)
);
msg.create();
String targetId = "g" + mLiveUid;
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
}

View File

@ -34,7 +34,8 @@ import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveChooseClassActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.adapter.LiveReadyShareAdapter;
import com.yunbao.common.bean.LiveRoomTypeBean;
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
@ -123,7 +124,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
@Override
public void beforeCamera() {
((LiveSwAnchorActivity) mContext).beforeCamera();
((LiveRyAnchorActivity) mContext).beforeCamera();
}
@Override
@ -218,8 +219,8 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
public void openWishListWindow() {
LiveWishListDialogFragment fragment = new LiveWishListDialogFragment();
if (mContext instanceof LiveSwAnchorActivity){
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "RY");
if (mContext instanceof LiveRyAnchorActivity){
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
}
}
@ -281,14 +282,14 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
* 切换镜头
*/
private void toggleCamera() {
((LiveSwAnchorActivity) mContext).toggleCamera();
((LiveRyAnchorActivity) mContext).toggleCamera();
}
/**
* 关闭
*/
private void close() {
((LiveSwAnchorActivity) mContext).endLives();
((LiveRyAnchorActivity) mContext).endLives();
}
/**
@ -309,7 +310,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
* 设置美颜
*/
private void beauty() {
((LiveSwAnchorActivity) mContext).beauty();
((LiveRyAnchorActivity) mContext).beauty();
// Intent intent = new Intent(mContext, Beauty360Activity3.class);
// mContext.startActivity(intent);
@ -324,7 +325,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
LiveRoomTypeDialogFragment fragment = new LiveRoomTypeDialogFragment();
fragment.setArguments(bundle);
fragment.setCallback(mLiveTypeCallback);
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
}
/**
@ -398,7 +399,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
mLiveTimeCoin = coin;
}
});
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
}
public void hide() {
@ -418,7 +419,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
* 点击开始直播按钮
*/
private void startLive() {
boolean startPreview = ((LiveSwAnchorActivity) mContext).isStartPreview();
boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview();
// if (!startPreview) {
// ToastUtil.show(R.string.please_wait);
// return;
@ -480,7 +481,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
UserBean u = appConfig.getUserBean();
((LiveSwAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
((LiveRyAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
//
// RongChatRoomClient.getInstance().joinChatRoom("g" + appConfig.getUid(), -1, new IRongCoreCallback.OperationCallback() {
// @Override

View File

@ -148,6 +148,7 @@ import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.adapter.LiveChatAdapter;
@ -399,6 +400,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private View quick_gift_reminder;
private int guardType = 0;
private static boolean isSw;
public LiveRoomViewHolder setGuardType(int guardType) {
this.guardType = guardType;
return this;
@ -545,8 +548,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager,boolean isSw) {
super(context, parentView);
this.isSw =isSw;
Contexts = context;
this.forAct = forActivity;
// this.isRy = isRys;
@ -3607,8 +3611,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void callback(Integer isAttention) {
if (isAttention == 1) {
LiveActivity.sendSystemMessage(
CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
if(isSw){
LiveActivity.sendSystemMessageSw(
CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
}else{
LiveActivity.sendSystemMessageRy(
CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
}
}
}
});
@ -3676,16 +3685,32 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (isStayRoomfive) {
showFollowDialog(mNameText, mAvatarUrl, mContext);
} else {
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
if(mContext instanceof LiveSwAnchorActivity){
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}else{
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
} else {
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
if(mContext instanceof LiveSwAnchorActivity){
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}else{
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
} else {
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
if(mContext instanceof LiveSwAnchorActivity){
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}else{
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
}
}

View File

@ -174,7 +174,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (yaoqing.size() < 3) {
if (PKing == false) {
((LiveSwAnchorActivity) mContext).openLinkMicAnchorWindow(true);
((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
} else {
ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
}
@ -242,7 +242,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
* 关闭直播
*/
private void close() {
((LiveSwAnchorActivity) mContext).closeLive();
((LiveRyAnchorActivity) mContext).closeLive();
}
@Override
@ -258,11 +258,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (mBtnFunction != null) {
mBtnFunction.setImageDrawable(mDrawable1);
}
if(mContext instanceof LiveSwAnchorActivity){
((LiveSwAnchorActivity) mContext).showFunctionDialog();
}else{
((LiveRyAnchorActivity) mContext).showFunctionDialog();
}
((LiveRyAnchorActivity) mContext).showFunctionDialog();
}
/**
@ -295,7 +291,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
* 发起主播连麦pk
*/
private void applyLinkMicPk() {
((LiveSwAnchorActivity) mContext).applyLinkMicPk();
((LiveRyAnchorActivity) mContext).applyLinkMicPk();
}
public void setLinkMicEnable(boolean linkMicEnable) {

View File

@ -110,6 +110,7 @@ import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.utils.LiveImDeletUtil;
@ -393,7 +394,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
}
mLivePlayViewHolder.initSwEngine(mLiveBean.getUid());
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager());
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager(),isSw);
mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer);
mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView());
mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null);
@ -1240,11 +1241,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (!mFirstConnectSocket) {
mFirstConnectSocket = true;
if (mLiveType == Constants.LIVE_TYPE_PAY || mLiveType == Constants.LIVE_TYPE_TIME) {
SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1);
if(isSw){
SocketSwChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1);
}else{
SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1);
}
}
if(isSw){
SocketSwChatUtil.getFakeFans(mLiveBean.getUid());
}else{
SocketRyChatUtil.getFakeFans(mLiveBean.getUid());
}
SocketRyChatUtil.getFakeFans(mLiveBean.getUid());
}
}
}
@ -2117,8 +2124,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
MobclickAgent.onEvent(mContext, "live_room_light", "直播间点亮");
mLighted = true;
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
SocketRyChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType);
if(isSw){
SocketSwChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType);
}else{
SocketRyChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType);
}
}
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.playLightAnim();
@ -2176,9 +2186,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* 更新主播映票数
*/
public void sendUpdateVotesMessage() {
SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal);
if(isSw){
SocketSwChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal);
}else{
SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal);
}
}
public void onFollowEvent(FollowEvent e) {