Exemple #1
0
        public void Dispose()
        {
            if (CallInvite != null)
            {
                CallInvite.Reject();
                CallInvite.Dispose();
                CallInvite = null;
            }

            if (Call != null)
            {
                Call.Disconnect();
                Call.Dispose();
                Call = null;
            }

            if (_callDelegate != null)
            {
                _callDelegate.CallDidConnectEvent                -= CallDelegateOnCallDidConnectEvent;
                _callDelegate.CallDidDisconnectWithErrorEvent    -= CallDelegateOnCallDidDisconnectWithError;
                _callDelegate.CallDidFailToConnectWithErrorEvent -= CallDelegateOnCallDidFailToConnectWithErrorEvent;
                _callDelegate = null;
            }

            if (_notificationDelegate != null)
            {
                _notificationDelegate.CallInviteReceivedEvent -= NotificationDelegateOnCallInviteReceivedEvent;
                _notificationDelegate.NotificationErrorEvent  -= NotificationDelegateOnNotificationErrorEvent;
                _notificationDelegate = null;
            }
        }
Exemple #2
0
        public void StartCall(ActiveCallbackDelegate completionHandler)
        {
            // todo: make sure the start call and call status cahnged events are handled correctly.

            callDelegate = new ValidTVOCallDelegate(completionHandler, this);
            // todo: make the delegate methods call the relevant ACTION delegates (connect/hangup)

            NSDictionary <NSString, NSString> twimlParam = new NSDictionary <NSString, NSString>();

            // The application needs to use this method to set up the AVAudioSession
            // with desired configuration before letting the CallKit framework activate the audio session.
            TwilioVoice.SharedInstance.ConfigureAudioSession();

            var client = new RestClient("http://privatevoice.azurewebsites.net/");

            var request = new RestRequest("BurnerPhone/Token?clientName=test", Method.GET);

            //request.AddParameter("To", "+17143913337");
            //request.AddParameter("From", "+15416677319");
            //request.AddParameter("Body", "Yo yo yo remove the json!");

            client.Authenticator = new RestSharp.Authenticators.HttpBasicAuthenticator("ACda7fae80dbacc70808a453daf19951db", "c50527004eebf9ff58cb3749f51d540f");

            var response = new RestResponse();

            Task.Run(async() =>
            {
                response = await GetResponseContentAsync(client, request) as RestResponse;
            }).Wait();


            var output = response.Content;

            Console.WriteLine("JWT= " + output);

            callInstance = TwilioVoice.SharedInstance.Call(
                output,
                twimlParam,
                callDelegate
                );

            // Simulate the call starting successfully
            completionHandler(true);

            //// Simulate making a starting and completing a connection
            //DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 3000), () =>
            //{
            //	// Note that the call is starting
            //	isConnecting = true;

            //	// Simulate pause before connecting
            //	DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 1500), () =>
            //		{
            //			// Note that the call has connected
            //			isConnecting = false;
            //			isConnected = true;
            //		});
            //});
        }
Exemple #3
0
 public void MakeCall(string accessToken, NSDictionary <NSString, NSString> parameters)
 {
     if (accessToken == null || Call != null)
     {
         return;
     }
     Call = TwilioVoice.Call(accessToken, parameters, _callDelegate);
 }
        public override void CallDidDisconnect(TVOCall call)
        {
            //		NSLog(@"callDidDisconnect:");

            _currentCall.isConnected = false;
            //_currentCall.ConnectedChanged();
            //[self performEndCallActionWithUUID:call.uuid];

            //self.call = nil;

            //[self.placeCallButton setTitle:@"Place Outgoing Call" forState:UIControlStateNormal];

            //[self toggleUIState:YES];
        }
        public override void Call(TVOCall call, NSError error)
        {
            //		NSLog(@"call:didFailWithError: %@", [error localizedDescription]);

            //      DispatchQueue.MainQueue.DispatchAsync(() =>
            //{
            //    // Note that the call is starting
            //    isConnecting = true;
            //});
            //[self performEndCallActionWithUUID:call.uuid];

            //self.call = nil;
            //[self toggleUIState:YES];
            //[self stopSpin];

            _completionHandler(false);
        }
        public override void CallDidConnect(TVOCall call)
        {
            _currentCall.isConnected = true;
            //_currentCall.ConnectedChanged();

            //      self.call = call;

            //[self.placeCallButton setTitle:@"Hang Up" forState:UIControlStateNormal];

            //[self toggleUIState:YES];
            //[self stopSpin];
            RouteAudioToSpeaker();


            //DispatchQueue.MainQueue.DispatchAfter(() =>
            //      {
            //          // Note that the call has connected
            //          isConnecting = false;
            //          isConnected = true;
            //      });
            _completionHandler(true);
        }
Exemple #7
0
 private void CallDelegateOnCallDidConnectEvent(object sender, TVOCall e)
 {
     Call = e;
     CallDidConnect?.Invoke(this, EventArgs.Empty);
 }
Exemple #8
0
 public void AcceptCallInvite()
 {
     LogHelper.Call(nameof(TwilioVoiceHelper), nameof(AcceptCallInvite));
     Call       = CallInvite?.AcceptWithDelegate(_callDelegate);
     CallInvite = null;
 }