优化客户端音乐播放推送规则
This commit is contained in:
parent
18647a3951
commit
0e1a4d830a
@ -70,54 +70,51 @@ public class MusicActionCommand extends ActionCommand implements IActionCommand
|
||||
}
|
||||
|
||||
protected Mono<Boolean> sendMessage(Action action, BaseSession baseSession, BaseMessageResp resp){
|
||||
return baseWebSocketService.sendMessage(action, baseSession, resp).map(b -> {
|
||||
//客户端推送的
|
||||
if(baseSession instanceof UserSession) {
|
||||
log.info("推送Box播放音乐");
|
||||
BoxSession boxSession = baseWebSocketService.getBoxSessionWithSn(baseSession.getSn());
|
||||
if(boxSession != null){
|
||||
baseWebSocketService.sendMsg(boxSession, resp);
|
||||
//记录音乐状态
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
//去掉内存中音乐同步对象
|
||||
boxSession.setMusic(null);
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
boxSession.setMusic(resp.getMusic());
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
if(baseSession instanceof UserSession) {
|
||||
log.info("推送Box播放音乐");
|
||||
BoxSession boxSession = baseWebSocketService.getBoxSessionWithSn(baseSession.getSn());
|
||||
if(boxSession != null){
|
||||
baseWebSocketService.sendMsg(boxSession, resp);
|
||||
//记录音乐状态
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
//去掉内存中音乐同步对象
|
||||
boxSession.setMusic(null);
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
log.info("设备sn:{}不在线,无法播放", baseSession.getSn());
|
||||
resp.setText("设备不在线,无法播放");
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
//去掉内存中音乐同步对象
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
boxSession.setMusic(resp.getMusic());
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
}else{//果box的
|
||||
//记录音乐状态
|
||||
BaseSession userSession = baseWebSocketService.getUserSessionWithUserId(baseSession.getUserId());
|
||||
//记录音乐状态
|
||||
//去掉内存中音乐同步对象
|
||||
if(userSession != null){
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
baseSession.setMusic(null);
|
||||
userSession.setMusic(null);
|
||||
}else{
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
//如果在线推送用户端
|
||||
}else{
|
||||
log.info("设备sn:{}不在线,无法播放", baseSession.getSn());
|
||||
resp.setText("设备不在线,无法播放");
|
||||
baseSession.setMusic(null);
|
||||
resp.setMusic(null);
|
||||
resp.setType(AskTypeEnum.TTS.getCode());
|
||||
|
||||
}
|
||||
}else{//果box的
|
||||
//记录音乐状态
|
||||
BaseSession userSession = baseWebSocketService.getUserSessionWithUserId(baseSession.getUserId());
|
||||
//记录音乐状态
|
||||
//去掉内存中音乐同步对象
|
||||
if(userSession != null){
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
baseSession.setMusic(null);
|
||||
userSession.setMusic(null);
|
||||
}else{
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
userSession.setMusic(resp.getMusic());
|
||||
}
|
||||
//如果在线推送用户端
|
||||
}else{
|
||||
if(resp.getMusic().getPlay().equals(PlayEnum.STOP.getCode())){
|
||||
baseSession.setMusic(null);
|
||||
}else{
|
||||
baseSession.setMusic(resp.getMusic());
|
||||
}
|
||||
}
|
||||
return b;
|
||||
});
|
||||
|
||||
}
|
||||
return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ public class BaseSession {
|
||||
/***
|
||||
* 设备序列号
|
||||
*/
|
||||
protected String sn;
|
||||
protected String sn = "";
|
||||
protected WebSocketSession session;
|
||||
protected FluxSink<WebSocketMessage> sink;
|
||||
|
||||
@ -32,7 +32,7 @@ public class BaseSession {
|
||||
/***
|
||||
* 用户id
|
||||
*/
|
||||
protected Long userId;
|
||||
protected Long userId = 0L;
|
||||
/***
|
||||
* 当前使用的BoxId,如果未绑定,那么就是0
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user