Exemple #1
0
        /// <summary>
        /// Allow the app to access the list of calls,  by UUID
        /// </summary>
        /// <param name="callManager"></param>
        public ProviderDelegate(ActiveCallManager callManager)
        {
            // Save connection to call manager
            CallManager = callManager;

            // Define handle types
            var handleTypes = new[] { (NSNumber)(int)CXHandleType.PhoneNumber };

            // Get Image Mask
            var maskImage = UIImage.FromFile("telephone_receiver.png");

            // Setup the initial configurations
            Configuration = new CXProviderConfiguration(localizedName: "MonkeyCall")
            {
                MaximumCallsPerCallGroup = 1,
                SupportedHandleTypes     = new NSSet <NSNumber>(handleTypes),
                //IconMaskImageData = maskImage.AsPNG(),
                RingtoneSound = "musicloop01.wav",

                //MaximumCallGroups = 3,
                //SupportsVideo = false
            };


            // TODO: WWDC 2016 11:12
            //if (CXProvider.authorization = Notddetermiened )
            // provider.requestAuthorization

            // Create a new provider
            Provider = new CXProvider(Configuration);

            // Attach this delegate
            Provider.SetDelegate(this, null);
        }
Exemple #2
0
        public override void PerformEndCallAction(CXProvider provider, CXEndCallAction action)
        {
            Console.WriteLine("CXProviderDelegate: PerformEndCallAction " + action.CallUuid);

            // Find requested call
            var call = CallManager.FindCall(action.CallUuid);

            // Found?
            if (call == null)
            {
                // No, inform system and exit
                action.Fail();
                return;
            }

            // Attempt to answer call
            call.EndCall((successful) =>
            {
                // Was the call successfully answered?
                if (successful)
                {
                    // Remove call from manager's queue
                    CallManager.Calls.Remove(call);

                    // Yes, inform system
                    action.Fulfill();
                }
                else
                {
                    // No, inform system
                    action.Fail();
                }
            });
        }
Exemple #3
0
        /// <summary>
        /// Causes the VOIP app to be handled at a higher priority
        ///  WWDC 2016 15:54
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="audioSession"></param>
        public override void DidDeactivateAudioSession(CXProvider provider, AVFoundation.AVAudioSession audioSession)
        {
            Console.WriteLine("CXProviderDelegate: DidDeactivateAudioSession ");

            // End the calls audio session and restart any non-call
            // related audio
        }
Exemple #4
0
        public ProviderDelegate(ActiveCallManager callManager)
        {
            // Save connection to call manager
            CallManager = callManager;

            // Define handle types
            var handleTypes = new[] { (NSNumber)(int)CXHandleType.PhoneNumber };

            // Get Image Mask
            var maskImage = UIImage.FromFile("telephone_receiver.png");

            // Setup the initial configurations
            Configuration = new CXProviderConfiguration("MonkeyCall")
            {
                MaximumCallsPerCallGroup = 1,
                SupportedHandleTypes     = new NSSet <NSNumber>(handleTypes),
                IconTemplateImageData    = maskImage.AsPNG(),
                // IconMaskImageData = maskImage.AsPNG(),
                RingtoneSound = "musicloop01.wav"
            };

            // Create a new provider
            Provider = new CXProvider(Configuration);

            // Attach this delegate
            Provider.SetDelegate(this, null);
        }
Exemple #5
0
        public override void PerformAnswerCallAction(CXProvider provider, CXAnswerCallAction action)
        {
            // Find requested call
            var call = CallManager.FindCall(action.CallUuid);

            // Found?
            if (call == null)
            {
                // No, inform system and exit
                action.Fail();
                return;
            }

            // Attempt to answer call
            call.AnswerCall((successful) => {
                // Was the call successfully answered?
                if (successful)
                {
                    // Yes, inform system
                    action.Fulfill();
                }
                else
                {
                    // No, inform system
                    action.Fail();
                }
            });
        }
Exemple #6
0
        /// <summary>
        /// Causes the VOIP app to be handled at a higher priority
        ///  WWDC 2016 15:54
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="audioSession"></param>
        public override void DidActivateAudioSession(CXProvider provider, AVFoundation.AVAudioSession audioSession)
        {
            Console.WriteLine("CXProviderDelegate: DidActivateAudioSession ");

            // The application needs to use this method to signal the SDK to start audio I/O
            // units when receiving the audio activation callback of CXProviderDelegate.
            TwilioVoice.SharedInstance.StartAudioDevice();
        }
Exemple #7
0
        public override void PerformStartCallAction(CXProvider provider, CXStartCallAction action)
        {
            Console.WriteLine("CXProviderDelegate: PerformStartCallAction");

            // Create new call record
            var activeCall = new ActiveCall(action.CallUuid, action.CallHandle.Value, true);

            // Monitor state changes
            activeCall.StartingConnectionChanged += (call) =>
            {
                if (call.isConnecting)
                {
                    // Inform system that the call is starting
                    Provider.ReportConnectingOutgoingCall(call.UUID, call.StartedConnectingOn.ToNSDate());
                }
            };

            activeCall.ConnectedChanged += (call) =>
            {
                if (call.isConnected)
                {
                    // Inform system that the call has connected
                    provider.ReportConnectedOutgoingCall(call.UUID, call.ConnectedOn.ToNSDate());
                }
            };

            // Start call
            activeCall.StartCall((successful) =>
            {
                // Was the call able to be started?
                if (successful)
                {
                    // Yes, inform the system
                    action.Fulfill();

                    // Add call to manager
                    CallManager.Calls.Add(activeCall);
                }
                else
                {
                    // No, inform system
                    action.Fail();
                }
            });
        }
Exemple #8
0
        public override void PerformSetHeldCallAction(CXProvider provider, CXSetHeldCallAction action)
        {
            // Find requested call
            var call = CallManager.FindCall(action.CallUuid);

            // Found?
            if (call == null)
            {
                // No, inform system and exit
                action.Fail();
                return;
            }

            // Update hold status
            call.IsOnHold = action.OnHold;

            // Inform system of success
            action.Fulfill();
        }
Exemple #9
0
 public override void DidReset(CXProvider provider)
 {
     Console.WriteLine("CXProviderDelegate: DidReset");
     // Remove all calls
     CallManager.Calls.Clear();
 }
Exemple #10
0
        public override void TimedOutPerformingAction(CXProvider provider, CXAction action)
        {
            Console.WriteLine("CXProviderDelegate: TimedOutPerformingAction ");

            // Inform user that the action has timed out
        }
Exemple #11
0
 public override void DidReset(CXProvider provider)
 {
     // Remove all calls
     CallManager.Calls.Clear();
 }
Exemple #12
0
 public override void DidDeactivateAudioSession(CXProvider provider, AVFoundation.AVAudioSession audioSession)
 {
     // End the calls audio session and restart any non-call
     // related audio
 }
Exemple #13
0
 public override void DidActivateAudioSession(CXProvider provider, AVFoundation.AVAudioSession audioSession)
 {
     // Start the calls audio session here
 }
Exemple #14
0
 public override void TimedOutPerformingAction(CXProvider provider, CXAction action)
 {
     // Inform user that the action has timed out
 }