コード例 #1
0
        public void AcceptCallAsync(TLInputPhoneCall peer, TLString gb, TLPhoneCallProtocol protocol, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLAcceptCall {
                Peer = peer, GB = gb, Protocol = protocol
            };

            SendInformativeMessage("phone.acceptCall", obj, callback, faultCallback);
        }
コード例 #2
0
        private void ProcessAcceptedCall(TLPhoneCallAccepted phoneCallAccepted)
        {
            DispatchStateChanged(PhoneCallState.STATE_EXCHANGING_KEYS);

            if (!TLUtils.CheckGaAndGb(phoneCallAccepted.GB.Data, _secretP.Data))
            {
                CallFailed();
                return;
            }


            _authKey = MTProtoService.GetAuthKey(_aOrB, phoneCallAccepted.GB.ToBytes(), _secretP.ToBytes());
            var keyHash        = Utils.ComputeSHA1(_authKey);
            var keyFingerprint = new TLLong(BitConverter.ToInt64(keyHash, 12));

            var peer = new TLInputPhoneCall
            {
                Id         = phoneCallAccepted.Id,
                AccessHash = phoneCallAccepted.AccessHash
            };

            var protocol = new TLPhoneCallProtocol
            {
                Flags        = new TLInt(0),
                UdpP2P       = true,
                UdpReflector = true,
                MinLayer     = new TLInt(CALL_MIN_LAYER),
                MaxLayer     = new TLInt(CALL_MAX_LAYER)
            };

            _mtProtoService.ConfirmCallAsync(peer, TLString.FromBigEndianData(_ga), keyFingerprint, protocol,
                                             result =>
            {
                _call = result;
                InitiateActualEncryptedCall();
            },
                                             error =>
            {
                CallFailed();
            });
        }
コード例 #3
0
        public void StartOutgoingCall(TLInputUserBase userId)
        {
            var salt   = new Byte[256];
            var random = new SecureRandom();

            random.NextBytes(salt);

            var version      = _lastVersion ?? new TLInt(0);
            var randomLength = new TLInt(256);

            _mtProtoService.GetDHConfigAsync(version, randomLength,
                                             result =>
            {
                ConfigureDeviceForCall();
                ShowNotifications();
                StartConnectionSound();
                DispatchStateChanged(PhoneCallState.STATE_REQUESTING);

                _eventAggregator.Publish(new PhoneCallEventArgs("NotificationCenter.didStartedCall"));

                var dhConfig = result as TLDHConfig;
                if (dhConfig != null)
                {
                    if (!TLUtils.CheckPrime(dhConfig.P.Data, dhConfig.G.Value))
                    {
                        CallFailed();
                        return;
                    }

                    _secretP      = dhConfig.P;
                    _secretG      = dhConfig.G;
                    _secretRandom = dhConfig.Random;
                }

                for (var i = 0; i < 256; i++)
                {
                    salt[i] = (byte)(salt[i] ^ _secretRandom.Data[i]);
                }

                var gaBytes = MTProtoService.GetGB(salt, _secretG, _secretP);

                var protocol = new TLPhoneCallProtocol
                {
                    Flags        = new TLInt(0),
                    UdpP2P       = true,
                    UdpReflector = true,
                    MinLayer     = new TLInt(CALL_MIN_LAYER),
                    MaxLayer     = new TLInt(CALL_MAX_LAYER)
                };
                _ga        = gaBytes;
                var gaHash = Utils.ComputeSHA256(_ga);

                _mtProtoService.RequestCallAsync(userId, TLInt.Random(), TLString.FromBigEndianData(gaHash), protocol,
                                                 result2 =>
                {
                    _call = result2;
                    _aOrB = salt;
                    DispatchStateChanged(PhoneCallState.STATE_WAITING);
                    //if (_endCallAfterRequest)
                    //{
                    //    Hangup();
                    //    return;
                    //}
                },
                                                 error2 =>
                {
                });
            },
                                             error =>
            {
                Helpers.Execute.ShowDebugMessage("messages.getDHConfig error " + error);
                CallFailed();
            });
        }
コード例 #4
0
        public void ConfirmCallAsync(TLInputPhoneCall peer, TLString ga, TLLong keyFingerprint, TLPhoneCallProtocol protocol, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLConfirmCall {
                Peer = peer, GA = ga, KeyFingerprint = keyFingerprint, Protocol = protocol
            };

            SendInformativeMessage("phone.confirmCall", obj, callback, faultCallback);
        }
コード例 #5
0
        public void RequestCallAsync(TLInputUserBase userId, TLInt randomId, TLString gaHash, TLPhoneCallProtocol protocol, Action <TLPhonePhoneCall> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLRequestCall {
                UserId = userId, RandomId = randomId, GAHash = gaHash, Protocol = protocol
            };

            SendInformativeMessage("phone.requestCall", obj, callback, faultCallback);
        }