using System; using System.Threading.Tasks; using Chtn.CSharp.SDK.Core; using Chtn.CSharp.SDK.Models.Call; using Chtn.CSharpSDK.Core; namespace Chtn.CSharp.SDK.Services { public interface IBroadcastService { Task GetData(GetRtmpDataReq req); Task CreateService(CreateServerReq req); Task JoinWebSocketRoom(BroadcastJoinWsRoomReq req); } public class BroadcastServiceProvider : IBroadcastService { private readonly ApiClient _apiClient; private readonly string _channelId; private readonly string _categoryId; private readonly string _networkId; private readonly string _userId; private string _connId; public BroadcastServiceProvider( ApiClient apiClient, string channelId, string categoryId, string networkId, string userId) { _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); _channelId = channelId; _categoryId = categoryId; _networkId = networkId; _userId = userId; var ws = WebSocketHandler.GetInstance(); this._connId = ws.ConnId; ws.OnNewConnectionId += (newConnId) => this._connId = newConnId; } public async Task GetData(GetRtmpDataReq req) => await _apiClient.PostAsync("network/channel/rtmpData", req); public async Task CreateService(CreateServerReq req) => await _apiClient.PostAsync("network/channel/createServer", req); public async Task JoinWebSocketRoom(BroadcastJoinWsRoomReq req) => await _apiClient.PostAsync("v2/network/channel/joinWebSocketRoom", req); } }