コード例 #1
0
        public void DiscardCallAsync(TLInputPhoneCall peer, TLInt duration, TLPhoneCallDiscardReasonBase reason, TLLong connectionId, Action <TLUpdatesBase> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLDiscardCall {
                Peer = peer, Duration = duration, Reason = reason, ConnectionId = connectionId
            };

            const string caption = "phone.discardCall";

            SendInformativeMessage <TLUpdatesBase>(caption, obj,
                                                   result =>
            {
                var multiPts = result as IMultiPts;
                if (multiPts != null)
                {
                    _updatesService.SetState(multiPts, caption);
                }
                else
                {
                    ProcessUpdates(result, null, true);
                }

                callback.SafeInvoke(result);
            },
                                                   faultCallback);
        }
コード例 #2
0
        // This method is called when the incoming call processing is complete
        private void OnIncomingCallDialogDismissed(long callId, long callAccessHash, bool rejected)
        {
            Debug.WriteLine("[IncomingCallAgent] Incoming call processing is now complete.");

            if (rejected)
            {
                var deviceInfoService   = new Telegram.Api.Services.DeviceInfo.DeviceInfoService(GetInitConnection(), true, "BackgroundDifferenceLoader", 1);
                var cacheService        = new MockupCacheService();
                var updatesService      = new MockupUpdatesService();
                var transportService    = new TransportService();
                var connectionService   = new ConnectionService(deviceInfoService);
                var publicConfigService = new MockupPublicConfigService();

                var manualResetEvent = new ManualResetEvent(false);
                var mtProtoService   = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, publicConfigService);
                mtProtoService.Initialized += (o, e) =>
                {
                    var peer = new TLInputPhoneCall
                    {
                        Id         = new TLLong(callId),
                        AccessHash = new TLLong(callAccessHash)
                    };

                    var getStateAction = new TLDiscardCall
                    {
                        Peer         = peer,
                        Duration     = new TLInt(0),
                        Reason       = new TLPhoneCallDiscardReasonBusy(),
                        ConnectionId = new TLLong(0)
                    };
                    var actions = new List <TLObject> {
                        getStateAction
                    };

                    mtProtoService.SendActionsAsync(actions,
                                                    (request, result) =>
                    {
                        manualResetEvent.Set();
                    },
                                                    error =>
                    {
                        manualResetEvent.Set();
                    });
                };
                mtProtoService.InitializationFailed += (o, e) =>
                {
                    manualResetEvent.Set();
                };
                mtProtoService.Initialize();

#if DEBUG
                manualResetEvent.WaitOne();
#else
                manualResetEvent.WaitOne(TimeSpan.FromSeconds(10.0));
#endif

                mtProtoService.Stop();
            }

            this.Complete();
        }