...websocket先收到消息?

This commit is contained in:
wangliwen 2022-07-21 15:59:36 +08:00
parent 4b99279d87
commit 544a673f2a
1 changed files with 7 additions and 11 deletions

View File

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -141,16 +142,14 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
//全部用户
if (notice.getReceiverType() == ReceiverTypeEnum.ALL.value()) {
executor.execute(() -> {
CompletableFuture.runAsync(() -> {
//发送给全部用户
sendAllUser(notice);
});
executor.execute(() -> {
}, executor).thenRunAsync(() -> {
//通过WebSocket提示全部用户有新通知
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessageAll(message);
});
}, executor);
} else { //选中用户
List<Long> userIdList = new ArrayList<>();
@ -167,16 +166,13 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
}
List<Long> finalUserIdList = userIdList;
executor.execute(() -> {
//发送给选中用户
CompletableFuture.runAsync(() -> {
sendUser(notice, finalUserIdList);
});
executor.execute(() -> {
}, executor).thenRunAsync(() -> {
//通过WebSocket提示选中用户有新通知
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessage(finalUserIdList, message);
});
}, executor);
}
}