Пример #1
0
        public void Initialize(BackgroundTaskDeferral deferral)
        {
            if (_connection == null & _protoService == null)
            {
                VoIPCallTask.Log("Mediator initialized", "Creating proto service");

                var deviceInfoService = new DeviceInfoService();
                var eventAggregator   = new TelegramEventAggregator();
                var cacheService      = new InMemoryCacheService(eventAggregator);
                var updatesService    = new UpdatesService(cacheService, eventAggregator);
                var transportService  = new TransportService();
                var connectionService = new ConnectionService(deviceInfoService);
                var statsService      = new StatsService();
                var protoService      = new MTProtoService(deviceInfoService, updatesService, cacheService, transportService, connectionService, statsService);

                protoService.Initialized += (s, args) =>
                {
                    VoIPCallTask.Log("ProtoService initialized", "waiting for updates");

                    updatesService.LoadStateAndUpdate(() =>
                    {
                        VoIPCallTask.Log("Difference processed", "Difference processed");

                        if (_phoneCall == null)
                        {
                            VoIPCallTask.Log("Difference processed", "No call found in difference");

                            if (_systemCall != null)
                            {
                                _systemCall.NotifyCallEnded();
                            }
                        }
                    });
                };

                eventAggregator.Subscribe(this);
                protoService.Initialize();
                _protoService     = protoService;
                _transportService = transportService;
            }
            else
            {
                VoIPCallTask.Log("Mediator initialized", "_connection is null: " + (_connection == null));
            }

            _deferral    = deferral;
            _initialized = true;

            ProcessUpdates();
        }
Пример #2
0
        async void callObj_AnswerRequested(VoipPhoneCall sender, CallAnswerEventArgs args)
        {
            sender.NotifyCallActive();
            await Task.Delay(3000);

            sender.NotifyCallEnded();
        }
Пример #3
0
        public static void EndCall()
        {
            VoipPhoneCall          call     = VoipCall;
            BackgroundTaskDeferral deferral = RTCTaskDeferral;

            try
            {
                StopAudio();

                if (call != null)
                {
                    call.NotifyCallEnded();
                }
            }
            catch
            {
            }

            try
            {
                if (deferral != null)
                {
                    deferral.Complete();
                }
            }
            catch
            {
            }
            finally
            {
                VoipCall        = null;
                RTCTaskDeferral = null;
            }
        }
Пример #4
0
        public void StopVoip()
        {
            if (_voipCall != null)
            {
                _voipCall.NotifyCallEnded();
                _voipCall = null;
            }

            Hub.Instance.VoipTaskInstance?.CloseVoipTask();
        }
Пример #5
0
        private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            AppServiceDeferral deferral = args.GetDeferral();
            ValueSet           message  = args.Request.Message;

            switch (message["type"])
            {
            case "connect":
            {
                VoiceServerUpdate data  = JsonConvert.DeserializeObject <VoiceServerUpdate>(message["config"] as string);
                VoiceState        state = JsonConvert.DeserializeObject <VoiceState>(message["state"] as string);
                webrtcManager.SetRecordingDevice(message["inputId"] as string);
                webrtcManager.SetPlaybackDevice(message["outputId"] as string);
                ConnectToVoiceChannel(data, state);
            }
            break;

            case "disconnect":
                webrtcManager.Destroy();
                voipCall?.NotifyCallEnded();
                voipCall        = null;
                voiceConnection = null;
                break;

            case "voiceStateUpdate":
            {
                // Todo: handle here
                VoiceState state = JsonConvert.DeserializeObject <VoiceState>(message["state"] as string);
            }
            break;

            case "inputDevice":
                webrtcManager.SetRecordingDevice(message["id"] as string);
                break;

            case "outputDevice":
                webrtcManager.SetPlaybackDevice(message["id"] as string);
                break;
            }
            deferral.Complete();
        }
Пример #6
0
        public static void EndCall()
        {
            VoipPhoneCall          call     = VoipCall;
            BackgroundTaskDeferral deferral = RTCTaskDeferral;

            if (_voipCall == null)
            {
                return;
            }

            try
            {
                _myApp.hangupCall();
            }
            catch (Exception e)
            {
                _myApp.writeLog(2, e.Message);
            }

            try
            {
                if (call != null)
                {
                    call.NotifyCallEnded();
                }
            }
            catch
            {
            }

            try
            {
                if (deferral != null)
                {
                    deferral.Complete();
                }
            }
            catch
            {
            }
            finally
            {
                VoipCall        = null;
                RTCTaskDeferral = null;
            }
        }
 private static void Call_EndRequested(VoipPhoneCall sender, CallStateChangeEventArgs args)
 {
     sender.NotifyCallEnded();
 }
 private static void Call_RejectRequested(VoipPhoneCall sender, CallRejectEventArgs args)
 {
     sender.NotifyCallEnded();
 }
Пример #9
0
 private static void Call_RejectRequested(VoipPhoneCall sender, CallRejectEventArgs args)
 {
     sender.NotifyCallEnded();
 }
Пример #10
0
 private static void Call_EndRequested(VoipPhoneCall sender, CallStateChangeEventArgs args)
 {
     sender.NotifyCallEnded();
 }
Пример #11
0
 private void Call_EndRequested(VoipPhoneCall sender, CallStateChangeEventArgs args)
 {
     Current.StopAudio();
     sender.NotifyCallEnded();
     Current.VoipCall = null;
 }
Пример #12
0
 private void Call_RejectRequested(VoipPhoneCall sender, CallRejectEventArgs args)
 {
     Current.StopAudio();
     sender.NotifyCallEnded();
     Current.VoipCall = null;
 }
 private void Call_EndRequested(VoipPhoneCall sender, CallStateChangeEventArgs args)
 {
     Current.StopAudio();
     sender.NotifyCallEnded();
     Current.VoipCall = null;
 }
 private void Call_RejectRequested(VoipPhoneCall sender, CallRejectEventArgs args)
 {
     Current.StopAudio();
     sender.NotifyCallEnded();
     Current.VoipCall = null;
 }
 async void callObj_AnswerRequested(VoipPhoneCall sender, CallAnswerEventArgs args)
 {
     sender.NotifyCallActive();
     await Task.Delay(3000);
     sender.NotifyCallEnded();
 }