public void RequestCallAsync(TLInputUserBase userId, int randomId, byte[] gaHash, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null) { var obj = new TLPhoneRequestCall { UserId = userId, RandomId = randomId, GAHash = gaHash, Protocol = GetPhoneCallProtocol() }; const string caption = "phone.requestCall"; SendInformativeMessage(caption, obj, callback, faultCallback); }
internal async void OutgoingCall(int userId, long accessHash) { await UpdateStateAsync(TLPhoneCallState.Requesting); var coordinator = VoipCallCoordinator.GetDefault(); var call = coordinator.RequestNewOutgoingCall("Unigram", _user.FullName, "Unigram", VoipPhoneCallMedia.Audio); _outgoing = true; _systemCall = call; _systemCall.AnswerRequested += OnAnswerRequested; _systemCall.RejectRequested += OnRejectRequested; 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; g_a = MTProtoService.GetGB(salt, dh.G, dh.P); var request = new TLPhoneRequestCall { UserId = new TLInputUser { UserId = userId, AccessHash = accessHash }, RandomId = TLInt.Random(), GAHash = Utils.ComputeSHA256(g_a), Protocol = new TLPhoneCallProtocol { IsUdpP2p = true, IsUdpReflector = true, MinLayer = Telegram.Api.Constants.CallsMinLayer, MaxLayer = Telegram.Api.Constants.CallsMaxLayer, } }; var response = await SendRequestAsync <TLPhonePhoneCall>("phone.requestCall", request); if (response.IsSucceeded) { var update = new TLUpdatePhoneCall { PhoneCall = response.Result.PhoneCall }; Handle(update); await UpdateStateAsync(TLPhoneCallState.Waiting); } else { Debugger.Break(); } } }