| | |
| | | private void handleSubscription(String userId, String type, Payload payload) { |
| | | String sn = payload.getSn(); |
| | | boolean subscribe = payload.isSubscribe(); |
| | | String videoType = payload.getVideotype(); |
| | | String subscriptionKey = getSubscriptionKey(sn, type); // 生成唯一订阅标识 |
| | | |
| | | if (subscribe) { |
| | |
| | | // 开启直播 |
| | | // 开启直播逻辑 |
| | | System.out.println("开启直播"); |
| | | _liveStreamService.StartLiveStreaming(sn, videoType); |
| | | _liveStreamService.StartLiveStreaming(sn); |
| | | } |
| | | } else { |
| | | // 停止直播 |
| | |
| | | */ |
| | | private void removeUserAllSubscriptions(String userId) { |
| | | for (Map.Entry<String, Set<String>> entry : subscriptions.entrySet()) { |
| | | if (entry.getKey().contains(MessageType.LIVESTREAM.getType())) { |
| | | String sn = entry.getKey().split(":")[0]; |
| | | _liveStreamService.StopLiveStreaming(sn); |
| | | } |
| | | entry.getValue().remove(userId); |
| | | if (entry.getValue().isEmpty()) { |
| | | subscriptions.remove(entry.getKey()); |