1+ using System . Threading ;
2+
13namespace StreamVideo . Core . Sfu {
24using Signal = StreamVideo . v1 . Sfu . Signal ;
35// Generated by protoc-gen-twirpcs. DO NOT EDIT!
@@ -46,11 +48,12 @@ private static string parseJSONString(string jsonData, string key) {
4648 }
4749
4850 private delegate Resp doParsing < Resp > ( byte [ ] data ) where Resp : IMessage ;
49- private static async Task < Resp > DoRequest < Req , Resp > ( HttpClient client , string address , Req req , doParsing < Resp > parserFunc ) where Req : IMessage where Resp : IMessage {
51+ private static async Task < Resp > DoRequest < Req , Resp > ( HttpClient client , string address , Req req , doParsing < Resp > parserFunc , CancellationToken cancellationToken = default ) where Req : IMessage where Resp : IMessage {
5052 using ( var content = new ByteArrayContent ( req . ToByteArray ( ) ) ) {
5153 content . Headers . ContentType = CONTENT_TYPE_PROTOBUF ;
52- using ( HttpResponseMessage response = await client . PostAsync ( address , content ) ) {
54+ using ( HttpResponseMessage response = await client . PostAsync ( address , content , cancellationToken ) ) {
5355 var byteArr = await response . Content . ReadAsByteArrayAsync ( ) ;
56+ cancellationToken . ThrowIfCancellationRequested ( ) ;
5457 if ( ! response . IsSuccessStatusCode ) {
5558 string errorJSON = System . Text . Encoding . UTF8 . GetString ( byteArr , 0 , byteArr . Length ) ;
5659 throw createException ( errorJSON ) ;
@@ -61,44 +64,44 @@ private static async Task<Resp> DoRequest<Req, Resp>(HttpClient client, string a
6164 }
6265
6366 // SetPublisher sends the WebRTC offer for the peer connection used to publish A/V
64- public static async Task < Signal . SetPublisherResponse > SetPublisher ( HttpClient client , Signal . SetPublisherRequest req ) {
65- return await DoRequest < Signal . SetPublisherRequest , Signal . SetPublisherResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/SetPublisher" , req , Signal . SetPublisherResponse . Parser . ParseFrom ) ;
67+ public static async Task < Signal . SetPublisherResponse > SetPublisher ( HttpClient client , Signal . SetPublisherRequest req , CancellationToken cancellationToken = default ) {
68+ return await DoRequest < Signal . SetPublisherRequest , Signal . SetPublisherResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/SetPublisher" , req , Signal . SetPublisherResponse . Parser . ParseFrom , cancellationToken ) ;
6669 }
6770
6871 // answer is sent by the client to the SFU after receiving a subscriber_offer.
69- public static async Task < Signal . SendAnswerResponse > SendAnswer ( HttpClient client , Signal . SendAnswerRequest req ) {
70- return await DoRequest < Signal . SendAnswerRequest , Signal . SendAnswerResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/SendAnswer" , req , Signal . SendAnswerResponse . Parser . ParseFrom ) ;
72+ public static async Task < Signal . SendAnswerResponse > SendAnswer ( HttpClient client , Signal . SendAnswerRequest req , CancellationToken cancellationToken = default ) {
73+ return await DoRequest < Signal . SendAnswerRequest , Signal . SendAnswerResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/SendAnswer" , req , Signal . SendAnswerResponse . Parser . ParseFrom , cancellationToken ) ;
7174 }
7275
7376 // SendICECandidate sends an ICE candidate to the client
74- public static async Task < StreamVideo . v1 . Sfu . Signal . ICETrickleResponse > IceTrickle ( HttpClient client , StreamVideo . v1 . Sfu . Models . ICETrickle req ) {
75- return await DoRequest < StreamVideo . v1 . Sfu . Models . ICETrickle , StreamVideo . v1 . Sfu . Signal . ICETrickleResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/IceTrickle" , req , StreamVideo . v1 . Sfu . Signal . ICETrickleResponse . Parser . ParseFrom ) ;
77+ public static async Task < StreamVideo . v1 . Sfu . Signal . ICETrickleResponse > IceTrickle ( HttpClient client , StreamVideo . v1 . Sfu . Models . ICETrickle req , CancellationToken cancellationToken = default ) {
78+ return await DoRequest < StreamVideo . v1 . Sfu . Models . ICETrickle , StreamVideo . v1 . Sfu . Signal . ICETrickleResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/IceTrickle" , req , StreamVideo . v1 . Sfu . Signal . ICETrickleResponse . Parser . ParseFrom , cancellationToken ) ;
7679 }
7780
7881 // UpdateSubscribers is used to notify the SFU about the list of video subscriptions
7982 // TODO: sync subscriptions based on this + update tracks using the dimension info sent by the user
80- public static async Task < Signal . UpdateSubscriptionsResponse > UpdateSubscriptions ( HttpClient client , Signal . UpdateSubscriptionsRequest req ) {
81- return await DoRequest < Signal . UpdateSubscriptionsRequest , Signal . UpdateSubscriptionsResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/UpdateSubscriptions" , req , Signal . UpdateSubscriptionsResponse . Parser . ParseFrom ) ;
83+ public static async Task < Signal . UpdateSubscriptionsResponse > UpdateSubscriptions ( HttpClient client , Signal . UpdateSubscriptionsRequest req , CancellationToken cancellationToken = default ) {
84+ return await DoRequest < Signal . UpdateSubscriptionsRequest , Signal . UpdateSubscriptionsResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/UpdateSubscriptions" , req , Signal . UpdateSubscriptionsResponse . Parser . ParseFrom , cancellationToken ) ;
8285 }
8386
84- public static async Task < Signal . UpdateMuteStatesResponse > UpdateMuteStates ( HttpClient client , Signal . UpdateMuteStatesRequest req ) {
85- return await DoRequest < Signal . UpdateMuteStatesRequest , Signal . UpdateMuteStatesResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/UpdateMuteStates" , req , Signal . UpdateMuteStatesResponse . Parser . ParseFrom ) ;
87+ public static async Task < Signal . UpdateMuteStatesResponse > UpdateMuteStates ( HttpClient client , Signal . UpdateMuteStatesRequest req , CancellationToken cancellationToken = default ) {
88+ return await DoRequest < Signal . UpdateMuteStatesRequest , Signal . UpdateMuteStatesResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/UpdateMuteStates" , req , Signal . UpdateMuteStatesResponse . Parser . ParseFrom , cancellationToken ) ;
8689 }
8790
88- public static async Task < Signal . ICERestartResponse > IceRestart ( HttpClient client , Signal . ICERestartRequest req ) {
89- return await DoRequest < Signal . ICERestartRequest , Signal . ICERestartResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/IceRestart" , req , Signal . ICERestartResponse . Parser . ParseFrom ) ;
91+ public static async Task < Signal . ICERestartResponse > IceRestart ( HttpClient client , Signal . ICERestartRequest req , CancellationToken cancellationToken = default ) {
92+ return await DoRequest < Signal . ICERestartRequest , Signal . ICERestartResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/IceRestart" , req , Signal . ICERestartResponse . Parser . ParseFrom , cancellationToken ) ;
9093 }
9194
92- public static async Task < Signal . SendStatsResponse > SendStats ( HttpClient client , Signal . SendStatsRequest req ) {
93- return await DoRequest < Signal . SendStatsRequest , Signal . SendStatsResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/SendStats" , req , Signal . SendStatsResponse . Parser . ParseFrom ) ;
95+ public static async Task < Signal . SendStatsResponse > SendStats ( HttpClient client , Signal . SendStatsRequest req , CancellationToken cancellationToken = default ) {
96+ return await DoRequest < Signal . SendStatsRequest , Signal . SendStatsResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/SendStats" , req , Signal . SendStatsResponse . Parser . ParseFrom , cancellationToken ) ;
9497 }
9598
96- public static async Task < Signal . StartNoiseCancellationResponse > StartNoiseCancellation ( HttpClient client , Signal . StartNoiseCancellationRequest req ) {
97- return await DoRequest < Signal . StartNoiseCancellationRequest , Signal . StartNoiseCancellationResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/StartNoiseCancellation" , req , Signal . StartNoiseCancellationResponse . Parser . ParseFrom ) ;
99+ public static async Task < Signal . StartNoiseCancellationResponse > StartNoiseCancellation ( HttpClient client , Signal . StartNoiseCancellationRequest req , CancellationToken cancellationToken = default ) {
100+ return await DoRequest < Signal . StartNoiseCancellationRequest , Signal . StartNoiseCancellationResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/StartNoiseCancellation" , req , Signal . StartNoiseCancellationResponse . Parser . ParseFrom , cancellationToken ) ;
98101 }
99102
100- public static async Task < Signal . StopNoiseCancellationResponse > StopNoiseCancellation ( HttpClient client , Signal . StopNoiseCancellationRequest req ) {
101- return await DoRequest < Signal . StopNoiseCancellationRequest , Signal . StopNoiseCancellationResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/StopNoiseCancellation" , req , Signal . StopNoiseCancellationResponse . Parser . ParseFrom ) ;
103+ public static async Task < Signal . StopNoiseCancellationResponse > StopNoiseCancellation ( HttpClient client , Signal . StopNoiseCancellationRequest req , CancellationToken cancellationToken = default ) {
104+ return await DoRequest < Signal . StopNoiseCancellationRequest , Signal . StopNoiseCancellationResponse > ( client , "/twirp/stream.video.sfu.signal.SignalServer/StopNoiseCancellation" , req , Signal . StopNoiseCancellationResponse . Parser . ParseFrom , cancellationToken ) ;
102105 }
103106}
104107}
0 commit comments