implement CallService and WebRTC access support
This commit is contained in:
@@ -1,9 +1,31 @@
|
||||
namespace Chtn.CSharp.SDK.Models.Call
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Chtn.CSharp.SDK.Models.Call
|
||||
{
|
||||
public class InviteToCallReq
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string ChatId { get; set; }
|
||||
public string TargetId { get; set; }
|
||||
[JsonProperty("chatid")] public string ChatId { get; set; }
|
||||
[JsonProperty("userid")] public string UserId { get; set; }
|
||||
[JsonProperty("targetid")] public string TargetId { get; set; }
|
||||
[JsonProperty("type")] public string Type { get; set; }
|
||||
}
|
||||
|
||||
public class GetRTCAccessReq
|
||||
{
|
||||
[JsonProperty("chatid")] public string ChatId { get; set; }
|
||||
}
|
||||
|
||||
public class GetRTCAccessResp
|
||||
{
|
||||
[JsonProperty("iceServers")] public List<IceServer> IceServers { get; set; }
|
||||
[JsonProperty("token")] public string Token { get; set; }
|
||||
}
|
||||
|
||||
public class IceServer
|
||||
{
|
||||
[JsonProperty("urls")] public List<string> Urls { get; set; }
|
||||
[JsonProperty("username")] public string Username { get; set; }
|
||||
[JsonProperty("credential")] public string Credential { get; set; }
|
||||
}
|
||||
}
|
||||
29
Services/CallServiceMethods.cs
Normal file
29
Services/CallServiceMethods.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Chtn.CSharp.SDK.Core;
|
||||
using Chtn.CSharp.SDK.Models.Call;
|
||||
|
||||
namespace Chtn.CSharp.SDK.Services
|
||||
{
|
||||
public interface ICallService
|
||||
{
|
||||
Task InviteToCall(InviteToCallReq req);
|
||||
Task<GetRTCAccessResp> GetRTCAccess(GetRTCAccessReq req);
|
||||
}
|
||||
|
||||
public class CallServiceProvider: ICallService
|
||||
{
|
||||
private readonly ApiClient _apiClient;
|
||||
|
||||
public CallServiceProvider(ApiClient apiClient)
|
||||
{
|
||||
_apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
|
||||
}
|
||||
|
||||
public async Task InviteToCall(InviteToCallReq req) =>
|
||||
await _apiClient.PostAsync<InviteToCallReq, object>("v2/chat/rtcInvite", req);
|
||||
|
||||
public async Task<GetRTCAccessResp> GetRTCAccess(GetRTCAccessReq req) =>
|
||||
await _apiClient.PostAsync<GetRTCAccessReq, GetRTCAccessResp>("v2/chat/getRTCAccess", req);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user