修改socket
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.mogo.cloud.live.model;
|
||||
|
||||
public class CommandModel {
|
||||
private int type;
|
||||
private String videoChannel;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getVideoChannel() {
|
||||
return videoChannel;
|
||||
}
|
||||
|
||||
public void setVideoChannel(String videoChannel) {
|
||||
this.videoChannel = videoChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommandModel{" +
|
||||
"type=" + type +
|
||||
", videoChannel='" + videoChannel + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.mogo.cloud.live.socket;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.live.model.CommandModel;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.MsgBody;
|
||||
@@ -11,7 +12,8 @@ import com.mogo.cloud.socket.SocketManager;
|
||||
/**
|
||||
* Socket常链接工具类
|
||||
*/
|
||||
public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener, IMogoCloudSocketOnMessageListener {
|
||||
public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener,
|
||||
IMogoCloudSocketOnMessageListener<CommandModel> {
|
||||
private static final String TAG = "SocketMsgUtils";
|
||||
|
||||
private static final String appId = "liveStream";
|
||||
@@ -42,9 +44,10 @@ public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener, IMogoClou
|
||||
* 初始化长连接
|
||||
*/
|
||||
private void initSocket() {
|
||||
Log.i(TAG, "初始化长连接……");
|
||||
mSocketManager = SocketManager.getInstance();
|
||||
mSocketManager.init(mContext);
|
||||
mSocketManager.registerOnMessageListener(401016, this);
|
||||
mSocketManager.registerOnMessageListener(401017, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +64,7 @@ public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener, IMogoClou
|
||||
*/
|
||||
public void release() {
|
||||
mSocketManager.release();
|
||||
mSocketManager.unregisterOnMessageListener(401017, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,12 +74,12 @@ public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener, IMogoClou
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class target() {
|
||||
return Object.class;
|
||||
public Class<CommandModel> target() {
|
||||
return CommandModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(Object obj) {
|
||||
public void onMsgReceived(CommandModel obj) {
|
||||
Log.i(TAG, "onMsgReceived: obj=" + obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class LiveStreamUtils implements BizMessageListener {
|
||||
private static final String TAG = "LiveStreamUtils";
|
||||
private static final int POLL_TIME = 30 * 1000;
|
||||
// 循环上报摄像头可直播状态间隔时间
|
||||
private static final int PUSH_CAM_TIME = 10 * 1000;
|
||||
private static final int PUSH_CAM_TIME = 10 * 60 * 1000;
|
||||
private static final int PUSH_START = 0;
|
||||
private static final int PUSH_STOP = 1;
|
||||
private static final String C1 = "C_1"; //前置摄像头
|
||||
|
||||
Reference in New Issue
Block a user