[集群] 重构message消息接受返回值的方式
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.BasicParam;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -170,7 +172,7 @@ public interface IDeviceService {
|
||||
|
||||
WVPResult<SyncStatus> devicesSync(Device device);
|
||||
|
||||
DeferredResult<WVPResult<String>> deviceBasicConfig(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount);
|
||||
void deviceBasicConfig(Device device, BasicParam basicParam, ErrorCallback<String> callback);
|
||||
|
||||
DeferredResult<WVPResult<String>> deviceConfigQuery(Device device, String channelId, String configType);
|
||||
|
||||
|
||||
@@ -13,14 +13,12 @@ public interface IGbChannelPlayService {
|
||||
|
||||
void stopPlay(InviteSessionType type, CommonGBChannel channel, String stream);
|
||||
|
||||
void play(CommonGBChannel channel, Platform platform, ErrorCallback<StreamInfo> callback);
|
||||
void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void playGbDeviceChannel(CommonGBChannel channel, Boolean record, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void stopPlayDeviceChannel(InviteSessionType type, CommonGBChannel channel, String stream);
|
||||
|
||||
void playProxy(CommonGBChannel channel, ErrorCallback<StreamInfo> callback);
|
||||
void playProxy(CommonGBChannel channel, Boolean record, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void stopPlayProxy(CommonGBChannel channel);
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.event.MessageSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
||||
@@ -26,6 +27,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respons
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -655,26 +657,23 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeferredResult<WVPResult<String>> deviceBasicConfig(Device device, String channelId, String name, String expiration,
|
||||
String heartBeatInterval, String heartBeatCount) {
|
||||
public void deviceBasicConfig(Device device, BasicParam basicParam, ErrorCallback<String> callback) {
|
||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||
WVPResult<String> result = redisRpcService.deviceBasicConfig(device.getServerId(), device, channelId, name, expiration,
|
||||
heartBeatInterval, heartBeatCount);
|
||||
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>(3 * 1000L);
|
||||
deferredResult.setResult(result);
|
||||
return deferredResult;
|
||||
WVPResult<String> result = redisRpcService.deviceBasicConfig(device.getServerId(), device, basicParam);
|
||||
if (result.getCode() == ErrorCode.SUCCESS.getCode()) {
|
||||
callback.run(result.getCode(), result.getMsg(), result.getData());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DeferredResult<WVPResult<String>> result = new DeferredResult<>(3 * 1000L);
|
||||
try {
|
||||
sipCommander.deviceBasicConfigCmd(device, channelId, name, expiration, heartBeatInterval, heartBeatCount, event -> {
|
||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时"));
|
||||
sipCommander.deviceBasicConfigCmd(device, basicParam, event -> {
|
||||
callback.run(ErrorCode.ERROR100.getCode(), "操作超时", null);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
log.error("[命令发送失败] 设备配置: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -302,7 +302,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||
log.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", device.getDeviceId(), channel.getDeviceId());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
|
||||
}
|
||||
play(mediaServerItem, device, channel, null, callback);
|
||||
play(mediaServerItem, device, channel, null, userSetting.getRecordSip(), callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1661,11 +1661,11 @@ public class PlayServiceImpl implements IPlayService {
|
||||
}
|
||||
return;
|
||||
}
|
||||
inviteStreamService.removeInviteInfo( "rtp", inviteInfo);
|
||||
inviteStreamService.removeInviteInfo(inviteInfo);
|
||||
if (InviteSessionStatus.ok == inviteInfo.getStatus()) {
|
||||
try {
|
||||
log.info("[停止点播/回放/下载] {}/{}", device.getDeviceId(), channel.getDeviceId());
|
||||
cmder.streamByeCmd(device, channel.getDeviceId(), inviteInfo.getStream(), null, null);
|
||||
cmder.streamByeCmd(device, channel.getDeviceId(), "rtp", inviteInfo.getStream(), null, null);
|
||||
} catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) {
|
||||
log.error("[命令发送失败] 停止点播/回放/下载, 发送BYE: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user