|
|
|
|
@ -2,7 +2,6 @@ package org.yzh.web.service; |
|
|
|
|
|
|
|
|
|
import io.github.yezhihao.netmc.session.Session; |
|
|
|
|
import io.github.yezhihao.netmc.session.SessionManager; |
|
|
|
|
import io.netty.util.internal.ObjectUtil; |
|
|
|
|
import io.netty.util.internal.StringUtil; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
@ -32,7 +31,7 @@ public class SendCommandService { |
|
|
|
|
/** |
|
|
|
|
* 向设备发送推流命令的线程 |
|
|
|
|
*/ |
|
|
|
|
private Thread sendCommandToDeviceThread; |
|
|
|
|
private Thread thread; |
|
|
|
|
|
|
|
|
|
public void sendToDevice(String clientId) { |
|
|
|
|
if (!"40155591817".equals(clientId) |
|
|
|
|
@ -66,9 +65,9 @@ public class SendCommandService { |
|
|
|
|
* 重启自动发送推流命令 |
|
|
|
|
*/ |
|
|
|
|
public void restartSendToDevice() { |
|
|
|
|
if (sendCommandToDeviceThread != null && sendCommandToDeviceThread.isAlive()) { |
|
|
|
|
if (thread != null && thread.isAlive()) { |
|
|
|
|
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 停止原线程, 重新开启线程 "); |
|
|
|
|
sendCommandToDeviceThread.interrupt(); |
|
|
|
|
thread.interrupt(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sendToDevice(); |
|
|
|
|
@ -87,7 +86,7 @@ public class SendCommandService { |
|
|
|
|
|
|
|
|
|
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 开始执行 "); |
|
|
|
|
|
|
|
|
|
if (sendCommandToDeviceThread != null && sendCommandToDeviceThread.isAlive()) { |
|
|
|
|
if (thread != null && thread.isAlive()) { |
|
|
|
|
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 已有线程执行推流, 直接返回 "); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -95,7 +94,7 @@ public class SendCommandService { |
|
|
|
|
noticeCarStatus(null, BusinessConstant.DEFAULT_CHANNEL_NO, BusinessConstant.LIVE_STATUS_WAITING); |
|
|
|
|
|
|
|
|
|
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 启动线程, 开始执行发送推流命令 "); |
|
|
|
|
sendCommandToDeviceThread = new Thread(new Runnable() { |
|
|
|
|
thread = new Thread(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
for (Session session : sessionManager.all()) { |
|
|
|
|
@ -113,7 +112,7 @@ public class SendCommandService { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
sendCommandToDeviceThread.start(); |
|
|
|
|
thread.start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -158,8 +157,7 @@ public class SendCommandService { |
|
|
|
|
request.setStreamType(0); |
|
|
|
|
request.setTcpPort(4001); |
|
|
|
|
request.setUdpPort(0); |
|
|
|
|
Mono<APIResult<T0001>> resultMono = messageManager.requestR(request, T0001.class); |
|
|
|
|
APIResult<T0001> resultObj = resultMono.block(); |
|
|
|
|
APIResult<T0001> resultObj = messageManager.requestRV2(request); |
|
|
|
|
|
|
|
|
|
boolean sendResult = resultObj.isSuccess(); |
|
|
|
|
// 若命令发送失败, 返回false
|
|
|
|
|
|