新增功能 - 范围内的广播 - RangeBroadcast
iohao opened this issue · comments
新增功能的使用场景
范围内的广播,这个范围指的是,指定某些用户进行广播。
在执行广播前,开发者可以自定义业务逻辑,如
- 添加一些需要广播的用户
- 删除一些不需要接收广播的用户
- 可通过重写 logic、trick 方法来做一些额外扩展
for example
在某些业务场景下,能让语义更清晰
// example - 1
new RangeBroadcast(flowContext)
// 需要广播的数据
.setResponseMessage(responseMessage)
// 添加需要接收广播的用户
.addUserId(1)
.addUserId(2)
.addUserId(List.of(3L, 4L, 5L))
// 排除一些用户,被排除的用户将不会接收到广播
.removeUserId(1)
// 执行广播
.execute();
// example - 2
new RangeBroadcast(flowContext)
// 需要广播的数据
.setResponseMessage(cmdInfo, playerReady)
// 添加需要接收广播的用户
.addUserId(1)
// 执行广播
.execute();