[*] 日常优化
This commit is contained in:
@@ -1093,7 +1093,7 @@ public final class Taoyao implements ITaoyao {
|
||||
final String clientId = MapUtils.get(body, "clientId");
|
||||
final Room room = this.rooms.get(roomId);
|
||||
if(room == null) {
|
||||
Log.w(Taoyao.class.getSimpleName(), "无效房间:" + roomId);
|
||||
Log.w(Taoyao.class.getSimpleName(), "离开房间(无效房间):" + roomId);
|
||||
return;
|
||||
}
|
||||
room.closeRemoteClient(clientId);
|
||||
|
||||
@@ -2444,37 +2444,6 @@ class Taoyao extends RemoteClient {
|
||||
await me.mediaProduce();
|
||||
}
|
||||
|
||||
/**
|
||||
* 离开房间
|
||||
*/
|
||||
roomLeave() {
|
||||
const me = this;
|
||||
me.push(protocol.buildMessage("room::leave", {
|
||||
roomId: me.roomId
|
||||
}));
|
||||
me.closeRoomMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* 离开房间信令
|
||||
*
|
||||
* @param {*} message
|
||||
*/
|
||||
defaultRoomLeave(message) {
|
||||
const me = this;
|
||||
const { clientId } = message.body;
|
||||
if(clientId === me.clientId) {
|
||||
me.closeRoomMedia();
|
||||
} else if(me.remoteClients.has(clientId)) {
|
||||
const remoteClient = me.remoteClients.get(clientId);
|
||||
remoteClient.close();
|
||||
me.remoteClients.delete(clientId);
|
||||
console.debug("终端离开房间", clientId);
|
||||
} else {
|
||||
console.debug("离开终端无效", clientId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 媒体回调
|
||||
*
|
||||
@@ -3018,6 +2987,36 @@ class Taoyao extends RemoteClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 离开房间信令
|
||||
*/
|
||||
roomLeave() {
|
||||
this.push(protocol.buildMessage("room::leave", {
|
||||
roomId: this.roomId
|
||||
}));
|
||||
this.closeRoomMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* 离开房间信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
*/
|
||||
defaultRoomLeave(message) {
|
||||
const { clientId } = message.body;
|
||||
if(clientId === this.clientId) {
|
||||
this.closeRoomMedia();
|
||||
console.debug("终端离开房间", clientId);
|
||||
} else if(this.remoteClients.has(clientId)) {
|
||||
const remoteClient = this.remoteClients.get(clientId);
|
||||
remoteClient.close();
|
||||
this.remoteClients.delete(clientId);
|
||||
console.debug("终端离开房间", clientId);
|
||||
} else {
|
||||
console.debug("终端已经离开", clientId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间列表信令
|
||||
*
|
||||
|
||||
@@ -30,6 +30,10 @@ public enum ClientType {
|
||||
* 手机APP、平板APP
|
||||
*/
|
||||
MOBILE("移动端"),
|
||||
/**
|
||||
* 应用服务
|
||||
*/
|
||||
SERVER("应用服务"),
|
||||
/**
|
||||
* 其他智能终端
|
||||
*/
|
||||
@@ -47,7 +51,7 @@ public enum ClientType {
|
||||
/**
|
||||
* @return 是否是媒体终端
|
||||
*/
|
||||
public boolean mediaClient() {
|
||||
public boolean isClient() {
|
||||
return
|
||||
this == WEB ||
|
||||
this == CAMERA ||
|
||||
@@ -57,9 +61,16 @@ public enum ClientType {
|
||||
/**
|
||||
* @return 是否是媒体服务
|
||||
*/
|
||||
public boolean mediaServer() {
|
||||
public boolean isMedia() {
|
||||
return this == MEDIA;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 是否是应用服务
|
||||
*/
|
||||
public boolean isServer() {
|
||||
return this == SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value 类型
|
||||
@@ -81,13 +92,13 @@ public enum ClientType {
|
||||
*/
|
||||
public static final ClientType[] MEDIA_CLIENT_TYPE
|
||||
=
|
||||
Stream.of(ClientType.values()).filter(ClientType::mediaClient).toArray(ClientType[]::new);
|
||||
Stream.of(ClientType.values()).filter(ClientType::isClient).toArray(ClientType[]::new);
|
||||
|
||||
/**
|
||||
* 媒体服务类型列表
|
||||
*/
|
||||
public static final ClientType[] MEDIA_SERVER_TYPE
|
||||
=
|
||||
Stream.of(ClientType.values()).filter(ClientType::mediaServer).toArray(ClientType[]::new);
|
||||
Stream.of(ClientType.values()).filter(ClientType::isMedia).toArray(ClientType[]::new);
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ClientConfigProtocol extends ProtocolClientAdapter implements Appli
|
||||
// 日期时间
|
||||
config.put(Constant.DATETIME, DateUtils.format(LocalDateTime.now(), DateTimeStyle.YYYYMMDDHH24MMSS));
|
||||
// 媒体终端:媒体配置
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
config.put(Constant.MEDIA, this.mediaProperties);
|
||||
config.put(Constant.WEBRTC, this.webrtcProperties);
|
||||
} else {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ClientRegisterProtocol extends ProtocolClientAdapter {
|
||||
// 终端上线事件
|
||||
this.publishEvent(new ClientOnlineEvent(client));
|
||||
// 媒体服务注册:创建房间事件
|
||||
if(clientType.mediaServer()) {
|
||||
if(clientType.isMedia()) {
|
||||
this.publishEvent(new MediaServerRegisterEvent(client));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MediaAudioVolumeProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaServer()) {
|
||||
if(clientType.isMedia()) {
|
||||
room.broadcast(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -91,10 +91,10 @@ public class MediaConsumeProtocol extends ProtocolRoomAdapter implements Applica
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
final String producerId = MapUtils.get(body, Constant.PRODUCER_ID);
|
||||
final Producer producer = room.producer(producerId);
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
// 主动请求消费 || 消费通道准备就绪
|
||||
this.consume(room, room.clientWrapper(client), producer, message);
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
// 媒体通道准备就绪
|
||||
final String kind = MapUtils.get(body, Constant.KIND);
|
||||
final String streamId = MapUtils.get(body, Constant.STREAM_ID);
|
||||
|
||||
@@ -68,9 +68,9 @@ public class MediaConsumerCloseProtocol extends ProtocolRoomAdapter implements A
|
||||
log.debug("消费者无效:{} - {}", consumerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
consumer.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
consumer.remove();
|
||||
consumer.getConsumerClient().push(message);
|
||||
} else {
|
||||
|
||||
@@ -63,9 +63,9 @@ public class MediaConsumerPauseProtocol extends ProtocolRoomAdapter implements A
|
||||
log.debug("消费者无效:{} - {}", consumerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
consumer.pause();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
consumer.getConsumerClient().push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MediaConsumerRequestKeyFrameProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
body.put(Constant.CLIENT_ID, clientId);
|
||||
mediaClient.push(message);
|
||||
} else {
|
||||
|
||||
@@ -63,9 +63,9 @@ public class MediaConsumerResumeProtocol extends ProtocolRoomAdapter implements
|
||||
log.debug("消费者无效:{} - {}", consumerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
consumer.resume();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
consumer.getConsumerClient().push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class MediaConsumerScoreProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaServer()) {
|
||||
if(clientType.isMedia()) {
|
||||
room.broadcast(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MediaConsumerSetPreferredLayersProtocol extends ProtocolRoomAdapter
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
mediaClient.push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MediaConsumerSetPriorityProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
mediaClient.push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MediaConsumerStatusProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(mediaClient.request(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MediaDataConsumeProtocol extends ProtocolRoomAdapter {
|
||||
if(dataProducer == null) {
|
||||
throw MessageCodeException.of("没有提供数据生产:" + producerId);
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
final ClientWrapper dataConsumerClientWrapper = room.clientWrapper(client);
|
||||
final String dataConsumerClientId = dataConsumerClientWrapper.getClientId();
|
||||
final ClientWrapper dataProducerClientWrapper = dataProducer.getProducerClient();
|
||||
@@ -73,7 +73,7 @@ public class MediaDataConsumeProtocol extends ProtocolRoomAdapter {
|
||||
body.put(Constant.RTP_CAPABILITIES, dataConsumerClientWrapper.getRtpCapabilities());
|
||||
body.put(Constant.SCTP_CAPABILITIES, dataConsumerClientWrapper.getSctpCapabilities());
|
||||
mediaClient.push(message);
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
final String streamId = MapUtils.get(body, Constant.STREAM_ID);
|
||||
final String consumerId = MapUtils.get(body, Constant.CONSUMER_ID);
|
||||
final String dataConsumerClientId = MapUtils.get(body, Constant.CLIENT_ID);
|
||||
|
||||
@@ -68,9 +68,9 @@ public class MediaDataConsumerCloseProtocol extends ProtocolRoomAdapter implemen
|
||||
log.debug("数据消费者无效:{} - {}", consumerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
dataConsumer.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
dataConsumer.remove();
|
||||
dataConsumer.getConsumerClient().push(message);
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MediaDataConsumerStatusProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(mediaClient.request(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MediaDataProduceProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
final String streamId = Constant.STREAM_ID_PRODUCER.apply(Constant.DATA, clientId);
|
||||
body.put(Constant.CLIENT_ID, clientId);
|
||||
body.put(Constant.STREAM_ID, streamId);
|
||||
|
||||
@@ -64,9 +64,9 @@ public class MediaDataProducerCloseProtocol extends ProtocolRoomAdapter implemen
|
||||
log.debug("数据生产者无效:{} - {}", producerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
dataProducer.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
dataProducer.remove();
|
||||
dataProducer.getProducerClient().push(message);
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MediaDataProducerStatusProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(mediaClient.request(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MediaIceRestartProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(mediaClient.request(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MediaProduceProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
final String kind = MapUtils.get(body, Constant.KIND);
|
||||
final String streamId = Constant.STREAM_ID_PRODUCER.apply(kind, clientId);
|
||||
body.put(Constant.CLIENT_ID, clientId);
|
||||
|
||||
@@ -64,9 +64,9 @@ public class MediaProducerCloseProtocol extends ProtocolRoomAdapter implements A
|
||||
log.debug("生产者无效:{} - {}", producerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
producer.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
producer.remove();
|
||||
producer.getProducerClient().push(message);
|
||||
} else {
|
||||
|
||||
@@ -61,9 +61,9 @@ public class MediaProducerPauseProtocol extends ProtocolRoomAdapter implements A
|
||||
log.debug("生产者无效:{} - {}", producerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
producer.pause();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
producer.getProducerClient().push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -61,9 +61,9 @@ public class MediaProducerResumeProtocol extends ProtocolRoomAdapter implements
|
||||
log.debug("生产者无效:{} - {}", producerId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
producer.resume();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
producer.getProducerClient().push(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MediaProducerScoreProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaServer()) {
|
||||
if(clientType.isMedia()) {
|
||||
room.broadcast(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MediaProducerStatusProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(mediaClient.request(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(room.requestMedia(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -64,9 +64,9 @@ public class MediaTransportCloseProtocol extends ProtocolRoomAdapter implements
|
||||
log.debug("通道无效:{} - {}", transportId, clientType);
|
||||
return;
|
||||
}
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
transport.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
transport.remove();
|
||||
transport.getClient().push(message);
|
||||
} else {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MediaTransportStatusProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
client.push(mediaClient.request(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MediaTransportWebRtcConnectProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
final Message response = room.requestMedia(message);
|
||||
final Map<String, Object> responseBody = response.body();
|
||||
client.push(response);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MediaTransportWebRtcCreateProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
body.put(Constant.CLIENT_ID, clientId);
|
||||
final Message response = room.requestMedia(message);
|
||||
final Map<String, Object> responseBody = response.body();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MediaVideoOrientationChangeProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaServer()) {
|
||||
if(clientType.isMedia()) {
|
||||
room.broadcast(message);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -46,9 +46,9 @@ public class RoomCloseProtocol extends ProtocolRoomAdapter implements Applicatio
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
room.close();
|
||||
} else if(clientType.mediaServer()) {
|
||||
} else if(clientType.isMedia()) {
|
||||
room.remove();
|
||||
room.broadcast(message);
|
||||
} else {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RoomCreateProtocol extends ProtocolClientAdapter implements Applica
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
// WEB同步创建房间
|
||||
final Room room = this.roomManager.create(
|
||||
MapUtils.get(body, Constant.NAME),
|
||||
|
||||
@@ -76,7 +76,7 @@ public class RoomEnterProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
this.enter(clientId, room, client, message, body);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RoomExpelProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
final String expelClientId = MapUtils.get(body, Constant.CLIENT_ID);
|
||||
room.unicast(expelClientId, message);
|
||||
// 如果需要强制提出
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RoomInviteProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
final String inviteClientId = MapUtils.get(body, Constant.CLIENT_ID);
|
||||
body.put(Constant.PASSWORD, room.getPassword());
|
||||
this.clientManager.unicast(inviteClientId, message);
|
||||
|
||||
@@ -24,6 +24,10 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"roomId": "房间ID"
|
||||
}
|
||||
{
|
||||
"roomId" : "房间ID"
|
||||
"clientId": "离开终端ID"
|
||||
}
|
||||
""",
|
||||
@@ -43,7 +47,7 @@ public class RoomLeaveProtocol extends ProtocolRoomAdapter implements Applicatio
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(RoomLeaveEvent event) {
|
||||
final Room room = event.getRoom();
|
||||
final Room room = event.getRoom();
|
||||
final Client client = event.getClient();
|
||||
final Map<String, String> body = Map.of(
|
||||
Constant.ROOM_ID, room.getRoomId(),
|
||||
@@ -54,7 +58,7 @@ public class RoomLeaveProtocol extends ProtocolRoomAdapter implements Applicatio
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
if(clientType.isClient()) {
|
||||
room.leave(client);
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
|
||||
@@ -17,6 +17,9 @@ import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
@Protocol
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"roomId": "房间ID"
|
||||
}
|
||||
[
|
||||
{
|
||||
"name" : "房间名称",
|
||||
|
||||
Reference in New Issue
Block a user