public void AcceptCallAsync(TLInputPhoneCall peer, byte[] gb, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null) { var obj = new TLPhoneAcceptCall { Peer = peer, GB = gb, Protocol = GetPhoneCallProtocol() }; const string caption = "phone.acceptCall"; SendInformativeMessage(caption, obj, callback, faultCallback); }
private async void OnAnswerRequested(VoipPhoneCall sender, CallAnswerEventArgs args) { if (_phoneCall != null) { await UpdateStateAsync(TLPhoneCallState.ExchangingKeys); var reqConfig = new TLMessagesGetDHConfig { Version = 0, RandomLength = 256 }; var config = await SendRequestAsync <TLMessagesDHConfig>("messages.getDhConfig", reqConfig); if (config.IsSucceeded) { var dh = config.Result; if (!TLUtils.CheckPrime(dh.P, dh.G)) { return; } var salt = new byte[256]; var secureRandom = new SecureRandom(); secureRandom.NextBytes(salt); secretP = dh.P; a_or_b = salt; var g_b = MTProtoService.GetGB(salt, dh.G, dh.P); var request = new TLPhoneAcceptCall { GB = g_b, Peer = _phoneCall.ToInputPhoneCall(), Protocol = new TLPhoneCallProtocol { IsUdpP2p = true, IsUdpReflector = true, MinLayer = Telegram.Api.Constants.CallsMinLayer, MaxLayer = Telegram.Api.Constants.CallsMaxLayer, } }; var response = await SendRequestAsync <TLPhonePhoneCall>("phone.acceptCall", request); if (response.IsSucceeded) { _systemCall.NotifyCallActive(); Handle(new TLUpdatePhoneCall { PhoneCall = response.Result.PhoneCall }); } } } }
public async void Handle(TLUpdatePhoneCall update) { await VoIPConnection.Current.SendUpdateAsync(update); await Task.Delay(2000); //if (update.PhoneCall is TLPhoneCallDiscarded discarded) //{ // if (discarded.IsNeedRating) // { // Debugger.Break(); // } // if (discarded.IsNeedDebug) // { // Debugger.Break(); // } //} return; if (update.PhoneCall is TLPhoneCallRequested callRequested) { var reqReceived = new TLPhoneReceivedCall(); reqReceived.Peer = new TLInputPhoneCall(); reqReceived.Peer.Id = callRequested.Id; reqReceived.Peer.AccessHash = callRequested.AccessHash; ProtoService.SendRequestAsync <bool>("phone.receivedCall", reqReceived, null, null); var user = CacheService.GetUser(callRequested.AdminId) as TLUser; Execute.BeginOnUIThread(async() => { var dialog = await TLMessageDialog.ShowAsync(user.DisplayName, "CAAAALLL", "OK", "Cancel"); if (dialog == Windows.UI.Xaml.Controls.ContentDialogResult.Primary) { var config = await ProtoService.GetDHConfigAsync(0, 256); if (config.IsSucceeded) { var dh = config.Result; if (!TLUtils.CheckPrime(dh.P, dh.G)) { return; } secretP = dh.P; var salt = new byte[256]; var secureRandom = new SecureRandom(); secureRandom.NextBytes(salt); a_or_b = salt; var g_b = MTProtoService.GetGB(salt, dh.G, dh.P); var request = new TLPhoneAcceptCall { GB = g_b, Peer = new TLInputPhoneCall { Id = callRequested.Id, AccessHash = callRequested.AccessHash }, Protocol = new TLPhoneCallProtocol { IsUdpP2p = true, IsUdpReflector = true, MinLayer = 65, MaxLayer = 65, } }; var response = await ProtoService.SendRequestAsync <TLPhonePhoneCall>("phone.acceptCall", request); if (response.IsSucceeded) { } } } else { var req = new TLPhoneDiscardCall(); req.Peer = new TLInputPhoneCall(); req.Peer.Id = callRequested.Id; req.Peer.AccessHash = callRequested.AccessHash; req.Reason = new TLPhoneCallDiscardReasonHangup(); ProtoService.SendRequestAsync <TLPhonePhoneCall>("phone.acceptCall", req, null, null); } }); } else if (update.PhoneCall is TLPhoneCall call) { var auth_key = computeAuthKey(call); var g_a = call.GAOrB; var buffer = TLUtils.Combine(auth_key, g_a); var sha256 = Utils.ComputeSHA256(buffer); var emoji = EncryptionKeyEmojifier.EmojifyForCall(sha256); var user = CacheService.GetUser(call.AdminId) as TLUser; Execute.BeginOnUIThread(async() => { var dialog = await TLMessageDialog.ShowAsync(user.DisplayName, string.Join(" ", emoji), "OK"); }); } }