implement CallService and WebRTC access support

This commit is contained in:
2026-05-03 15:27:51 +02:00
parent a071e30065
commit d7d560cd91
2 changed files with 55 additions and 4 deletions

View File

@@ -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 class InviteToCallReq
{ {
public string UserId { get; set; } [JsonProperty("chatid")] public string ChatId { get; set; }
public string ChatId { get; set; } [JsonProperty("userid")] public string UserId { get; set; }
public string TargetId { 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; }
} }
} }

View 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);
}
}