[*] 日常优化

This commit is contained in:
acgist
2023-08-27 08:16:50 +08:00
parent 298378266a
commit be691965a6
5 changed files with 59 additions and 56 deletions

View File

@@ -1061,6 +1061,7 @@ public final class Taoyao implements ITaoyao {
private void roomInivte(Message message, Map<String, Object> body) { private void roomInivte(Message message, Map<String, Object> body) {
final String roomId = MapUtils.get(body, "roomId"); final String roomId = MapUtils.get(body, "roomId");
final String password = MapUtils.get(body, "password"); final String password = MapUtils.get(body, "password");
// 安卓可以同时进入多个房间
this.roomEnter(roomId, password); this.roomEnter(roomId, password);
} }

View File

@@ -2391,59 +2391,6 @@ class Taoyao extends RemoteClient {
} }
} }
/**
* 踢出终端信令
*
* @param {*} clientId 终端ID
*/
roomExpel(clientId) {
const me = this;
me.push(protocol.buildMessage("room::expel", {
roomId: me.roomId,
clientId,
}));
}
/**
* 踢出终端信令
*
* @param {*} message 消息
*/
async defaultRoomExpel(message) {
const me = this;
me.roomLeave();
}
/**
* 邀请终端
*
* @param {*} clientId 终端ID
*/
roomInvite(clientId) {
const me = this;
me.push(protocol.buildMessage("room::invite", {
roomId: me.roomId,
clientId,
}));
}
/**
* 邀请终端信令
*
* @param {*} message 消息
*/
async defaultRoomInvite(message) {
const me = this;
// 默认自动进入:如果需要确认使用回调函数重写
const { roomId, password } = message.body;
if(me.roomId) {
this.callbackError("已经进入房间拒绝邀请");
return;
}
await me.roomEnter(roomId, password);
await me.mediaProduce();
}
/** /**
* 媒体回调 * 媒体回调
* *
@@ -2987,6 +2934,61 @@ class Taoyao extends RemoteClient {
} }
} }
/**
* 踢出房间信令
*
* @param {*} clientId 终端ID
*/
roomExpel(clientId) {
this.push(protocol.buildMessage("room::expel", {
roomId: this.roomId,
clientId,
}));
}
/**
* 踢出房间信令
*
* @param {*} message 信令消息
*/
async defaultRoomExpel(message) {
console.debug("收到提出房间信令", message);
this.roomLeave();
}
/**
* 邀请终端信令
*
* @param {*} clientId 终端ID
*/
roomInvite(clientId) {
this.push(protocol.buildMessage("room::invite", {
roomId: this.roomId,
clientId,
}));
}
/**
* 邀请终端信令
*
* @param {*} message 信令消息
*/
async defaultRoomInvite(message) {
// 默认自动进入:如果需要确认使用回调函数重写
const {
roomId,
password
} = message.body;
// H5只能同时进入一个房间
if(this.roomId) {
this.callbackError("终端拒绝房间邀请", roomId);
return;
}
console.debug("房间邀请终端", roomId);
await this.roomEnter(roomId, password);
await this.mediaProduce();
}
/** /**
* 离开房间信令 * 离开房间信令
*/ */

View File

@@ -19,6 +19,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
*/ */
@Protocol @Protocol
@Description( @Description(
memo = "终端收到信令以后调用离开房间信令离开房间,没有实现强制在服务端提出。",
body = """ body = """
{ {
"roomId" : "房间ID", "roomId" : "房间ID",
@@ -40,8 +41,6 @@ public class RoomExpelProtocol extends ProtocolRoomAdapter {
if(clientType.isClient()) { if(clientType.isClient()) {
final String expelClientId = MapUtils.get(body, Constant.CLIENT_ID); final String expelClientId = MapUtils.get(body, Constant.CLIENT_ID);
room.unicast(expelClientId, message); room.unicast(expelClientId, message);
// 如果需要强制提出
// room.leave(this.clientManager.clients(expelClientId));
} else { } else {
this.logNoAdapter(clientType); this.logNoAdapter(clientType);
} }

View File

@@ -19,6 +19,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
*/ */
@Protocol @Protocol
@Description( @Description(
memo = "终端收到信令以后调用进入房间信令进入房间",
body = """ body = """
{ {
"roomId" : "房间ID", "roomId" : "房间ID",