Help - Search - Members - Calendar
Full Version: Unable to close the call tab when call status is failed
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
santosh
I downloaded the skype 2.5.0.141 and using "SKYPE4COMLib" in c# with windows 2000 as operating system.

My goal is to place a call programatically.

I tried using the following code

-------------------------------------------------------------------------------------
public SKYPE4COMLib.SkypeClass objSkype = new SKYPE4COMLib.SkypeClass();


SKYPE4COMLib.Call pCall = objSkype.PlaceCall("sampleskypeuser", "", "", "");

while (pCall.Status.ToString() == "clsRouting")
{
MessageBox.Show(pCall.Status.ToString());
}

if (pCall.Status.ToString() == "clsRinging" || pCall.Status.ToString() == "clsInprogress")
{

MessageBox.Show(pCall.Status.ToString());
pCall.Finish();

}

if (pCall.Status.ToString() == "clsFailed")
{
MessageBox.Show(pCall.Status.ToString());
MessageBox.Show(pCall.FailureReason.ToString());

pCall.Finish(); // Getting exception at this line (Call Failed)

}

------------------------------------------------------------------------------------

The above code works fine when the called number is working or skype user is online.

I could be able to finish the call (using pCall.Finish()) as soon as the phone starts ringing.
The call is successfully finished and "call tab" is closed on the skype interface.

(Please find the attached file to have a glimpse at the "call tab" which i am talking about)

But when the called number or skype user is offline , i am getting the call status as "clsFailed", Thats fine.

But in this scenario,I am still finding the "call tab" active in skype interface.In order to close this "call tab",
I tried to finish the call when call status is failed , but I ended up with exception(Saying Call failed).

I am forced to explicitly close the "call tab" by clicking the red button on the skype interface.

Could you please suggest me a way to close the "call tab" in the skype interface programatically
when the call status is failed ?
TheUberOverlord
QUOTE(santosh @ Fri Sep 22 2006, 10:44) [snapback]300339[/snapback]

I downloaded the skype 2.5.0.141 and using "SKYPE4COMLib" in c# with windows 2000 as operating system.

My goal is to place a call programatically.

I tried using the following code

-------------------------------------------------------------------------------------
public SKYPE4COMLib.SkypeClass objSkype = new SKYPE4COMLib.SkypeClass();
SKYPE4COMLib.Call pCall = objSkype.PlaceCall("sampleskypeuser", "", "", "");

while (pCall.Status.ToString() == "clsRouting")
{
MessageBox.Show(pCall.Status.ToString());
}

if (pCall.Status.ToString() == "clsRinging" || pCall.Status.ToString() == "clsInprogress")
{

MessageBox.Show(pCall.Status.ToString());
pCall.Finish();

}

if (pCall.Status.ToString() == "clsFailed")
{
MessageBox.Show(pCall.Status.ToString());
MessageBox.Show(pCall.FailureReason.ToString());

pCall.Finish(); // Getting exception at this line (Call Failed)

}

------------------------------------------------------------------------------------

The above code works fine when the called number is working or skype user is online.

I could be able to finish the call (using pCall.Finish()) as soon as the phone starts ringing.
The call is successfully finished and "call tab" is closed on the skype interface.

(Please find the attached file to have a glimpse at the "call tab" which i am talking about)

But when the called number or skype user is offline , i am getting the call status as "clsFailed", Thats fine.

But in this scenario,I am still finding the "call tab" active in skype interface.In order to close this "call tab",
I tried to finish the call when call status is failed , but I ended up with exception(Saying Call failed).

I am forced to explicitly close the "call tab" by clicking the red button on the skype interface.

Could you please suggest me a way to close the "call tab" in the skype interface programatically
when the call status is failed ?


Try using the "Skype" Button. This will force a Tab move, and this will force the tab to close as well.

You can test this by using this example, make a bad call, click the Skype button, and you will see the tab go away, look at the HTML source for what the Skype Button is doing and apply it to C# when you receive a call failed status.

http://testing.onlytherightanswers.com/skypebeta/Client.htm
santosh
QUOTE(TheUberOverlord @ Mon Sep 25 2006, 05:42) [snapback]301055[/snapback]

Try using the "Skype" Button. This will force a Tab move, and this will force the tab to close as well.

You can test this by using this example, make a bad call, click the Skype button, and you will see the tab go away, look at the HTML source for what the Skype Button is doing and apply it to C# when you receive a call failed status.

http://testing.onlytherightanswers.com/skypebeta/Client.htm



Thanks UberOverlord.
I checked the html code and unable to get it done in my c# application.
It is appreciable if you could add some code in c# to my existing code which i placed in the forum.
TheUberOverlord
QUOTE(santosh @ Mon Sep 25 2006, 03:22) [snapback]301109[/snapback]

Thanks UberOverlord.
I checked the html code and unable to get it done in my c# application.
It is appreciable if you could add some code in c# to my existing code which i placed in the forum.


If this was the event handler created for call status events from Skype, you could automate the tab removal by doing this:

CODE



public partial class Form1 : Form
    {
        public SKYPE4COMLib.SkypeClass objSkype = new SKYPE4COMLib.SkypeClass();

        public Form1()
        {
            InitializeComponent();
            objSkype.CallStatus += Skype_CallStatus;
        }


        public void Skype_CallStatus(Call call, TCallStatus status)
        {
            if (status == TCallStatus.clsFailed)
            {
                 objSkype.Client.Focus();
                 objSkype.Client.ButtonPressed("SKYPE");
                 objSkype.Client.ButtonReleased("SKYPE");
            }
            
         }

...................
santosh
Thanks Again,
Your suggestion is working.I have one more query.

My task is to place a call and as soon as the phone starts ringing , i want to diconnect the call.

When the call status is changing the event is getting fired and the corresponding function
(say Skype_CallStatus) gets called.

public void Skype_CallStatus(Call call, TCallStatus status)
{
if (status == TCallStatus.clsRinging )
{
objSkype.Client.Focus();
objSkype.Client.ButtonPressed("NO");
objSkype.Client.ButtonReleased("NO");
}

if (status == TCallStatus.clsFailed)
{
objSkype.Client.Focus();
objSkype.Client.ButtonPressed("NO");
objSkype.Client.ButtonReleased("NO");
}

}

With the above code my intention is to disconnect the call as soon as the phone starts ringing.
But the problem is, the call status is showing as "clsEarlyMedia" even though i am hearing the ringing tone on my headset.

I tried to debug the code and i found a very few times i could see the call status showing clsRinging .
In that scenario only i could be able to disconnect the call.

My doubt is why am i not getting the call status as "clsRinging" even though the phone is ringing at the receivers end.


TheUberOverlord
QUOTE(santosh @ Tue Sep 26 2006, 09:18) [snapback]301692[/snapback]

Thanks Again,
Your suggestion is working.I have one more query.

My task is to place a call and as soon as the phone starts ringing , i want to diconnect the call.

When the call status is changing the event is getting fired and the corresponding function
(say Skype_CallStatus) gets called.

public void Skype_CallStatus(Call call, TCallStatus status)
{
if (status == TCallStatus.clsRinging )
{
objSkype.Client.Focus();
objSkype.Client.ButtonPressed("NO");
objSkype.Client.ButtonReleased("NO");
}

if (status == TCallStatus.clsFailed)
{
objSkype.Client.Focus();
objSkype.Client.ButtonPressed("NO");
objSkype.Client.ButtonReleased("NO");
}

}

With the above code my intention is to disconnect the call as soon as the phone starts ringing.
But the problem is, the call status is showing as "clsEarlyMedia" even though i am hearing the ringing tone on my headset.

I tried to debug the code and i found a very few times i could see the call status showing clsRinging .
In that scenario only i could be able to disconnect the call.

My doubt is why am i not getting the call status as "clsRinging" even though the phone is ringing at the receivers end.


I am not sure what you are really trying to do but maybe using my above code modifed to do this.
CODE



public partial class Form1 : Form
    {
        public SKYPE4COMLib.SkypeClass objSkype = new SKYPE4COMLib.SkypeClass();

        public Form1()
        {
            InitializeComponent();
            objSkype.CallStatus += Skype_CallStatus;
        }


        public void Skype_CallStatus(Call call, TCallStatus status)
        {
            if (status == TCallStatus.clsFailed)
            {
                 objSkype.Client.Focus();
                 objSkype.Client.ButtonPressed("SKYPE");
                 objSkype.Client.ButtonReleased("SKYPE");
            }
            if ((status == TCallStatus.clsEarlyMedia) | (status == TCallStatus.clsRinging))
            {
                 objSkype.Client.Focus();
                 objSkype.Client.ButtonPressed("NO");
                 objSkype.Client.ButtonReleased("NO");
            }

            
         }

...................



After you see the routing status change to early media, all bets are off as to when actual ringing starts, you would be better off to assume that once routing has completed that the person being called could in fact be getting a ring voltage on their phone before you are informed their phone is ringing.

So basically, not knowing why you want to hang-up as soon as the call is connected in some way, the best way is to assume the call has started ringtone after the routing status has been seen and the early media status or ringing status is received.
santosh
Thankyou. Your suggestions are really helping a lot to me.

Now I am at the end of my application development. I am having a typical requirement such that
In our organization we are having hundreds of phone numbers and I need to find out whether a given phone number is working or not .

With your suggestions I could be able to successfully place a call using skype api.
Let me explain my problem with an example.

I am having two phone numbers with me one is +12484772178 a dead phone number( not working)
and another phone number is working.
Case 1:
When i tried to call the first dead phone number ( +12484772178 ) it is giving the status in the order
clsUnplaced --> clsRouting --> clsEarlyMedia
At this point of time I could be able to hear a tone on my head set saying this number is not in use e.t.c.
Case 2:
when i tried to call second phone number (working phone number) it is giving the status in the order

clsUnplaced --> clsRouting --> clsEarlyMedia

or

clsUnplaced --> clsRouting -->clsRinging --> clsEarlyMedia (sometimes)

if you observe carefully, In case 2 clsRinging status is missing sometimes when the status shifts from clsRouting to clsEarlyMedia.
I mean to say the call status event is not catching the clsRinging status always for calls made to working phone numbers.

How can i found out whether the phone number is working or not if both are giving the status in the same order (clsRinging status is missing in both the cases) ?

Ofcourse there is a chance in case 1 (calling dead phone number) to wait till the end , so that we can receive call status clsFailed , But i need to avoid this.


My doubt is why the call status is not returning as [b]clsRinging
always ,
even though the call made to the phone number is ringing successfully ?[/b]


TheUberOverlord
QUOTE(santosh @ Wed Sep 27 2006, 08:40) [snapback]302012[/snapback]

Thankyou. Your suggestions are really helping a lot to me.

Now I am at the end of my application development. I am having a typical requirement such that
In our organization we are having hundreds of phone numbers and I need to find out whether a given phone number is working or not .

With your suggestions I could be able to successfully place a call using skype api.
Let me explain my problem with an example.

I am having two phone numbers with me one is +12484772178 a dead phone number( not working)
and another phone number is working.
Case 1:
When i tried to call the first dead phone number ( +12484772178 ) it is giving the status in the order
clsUnplaced --> clsRouting --> clsEarlyMedia
At this point of time I could be able to hear a tone on my head set saying this number is not in use e.t.c.
Case 2:
when i tried to call second phone number (working phone number) it is giving the status in the order

clsUnplaced --> clsRouting --> clsEarlyMedia

or

clsUnplaced --> clsRouting -->clsRinging --> clsEarlyMedia (sometimes)

if you observe carefully, In case 2 clsRinging status is missing sometimes when the status shifts from clsRouting to clsEarlyMedia.
I mean to say the call status event is not catching the clsRinging status always for calls made to working phone numbers.

How can i found out whether the phone number is working or not if both are giving the status in the same order (clsRinging status is missing in both the cases) ?

Ofcourse there is a chance in case 1 (calling dead phone number) to wait till the end , so that we can receive call status clsFailed , But i need to avoid this.


My doubt is why the call status is not returning as [b]clsRinging
always ,
even though the call made to the phone number is ringing successfully ?[/b]


Well you have a real problem on your hands because if you are getting a "This number is not in service recording" as one example, you are at the mercy of the Phone interface equipment providing that recording, based on the load it currently has, sometimes it may answer quickly, other times it may take multiple rings.

Normally, when a number is not in service "This depends on the PBX or Telco equipment", there are 3 tones prior to the recording speaking, so, you could use some voice recognition software, combined with the new audio API interface in Skype to try and sense those tones. I can't see any other method to determine if a call is in progress if you are dealing with 1. A recording from a number not in service message. 2. An Answering machine, or a human being.

Once a call is answered, in Skype terms, the call is in progress, so there is no way to determine if the call became in progress due to human intervention, the only method would be to sense the 3 tones normally heard when a number is not in service.

Not sure if that is what you want to hear, but without some kind of voice recognition software to sense tones, I am not sure you can isolate non-working numbers by simply using Skype. If the number is plain "Dead" sure, but if a recording is being used to announce the number as "Not in Service" you have a complicating factor that only the ability to sense the tones, or even request a "Yes" or "No" voice response with some kind of timeout, but even with that you are at the mercy of the person answering the phone, who may decide to "Hang-Up" without saying the word "Yes" or "No".
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.