Make the call

That’s all there is to it. We now have complete “send a message” and “get the response” mechanisms implemented. To see them in action the simplest thing to do is to use it to call the Skype testing service. In the button’s click handler enter the following code:

If you run the program and click the button you will see the various Skype status message scrolling past and you should successfully place the test call. The WaitForSkype allows the program to continue as soon as the call is actually connected. Of course you need to write some code that handles the possibility that call will fail but this at least gives you the overall principle of how things are done.

You can see the status messages scrolling passed as the call progresses

Now that we have the basics implemented most of the rest of what there is to do consists of finding out what commands Skype supports and how to use them. Sometimes you will need to add additional processing to the existing methods. For an example of the sort of powerful things you can do easily, let’s record the incoming side of the call to a file. The command that does this job is the “ALTER CALL called SET OUTPUT destination” command. The problem is that to use it we need the call’s ID which is returned as part of status message during the call. Extracting the ID from the status is fairly easy and we can create a method to do the job:

This simply splits the string into separate words separated by spaces and returns the second item (remember the first item is items[0]) which is always the call ID in a call status message). Now all we have to do is to redefine the button’s click event handler:

Once we know that the call is in progress we get the call ID, construct the text for the command to save the audio output in a file called test.wav and send the command.

When the call is FINISHED you can open the test.wav file and hear the Skype testing service go through its usual script. You can divert the input audio stream in exactly the same way to build your own answering machine or automatic messaging system. If you are going to do something like this then don’t simply use the example program listed here. You need to implement a Skype object complete with asynchronous methods and events and you need to put in lots of error checking and recovery. It’s not difficult but it would have made for example code that was much more difficult to understand. Happy Skypeing.

If you would like the code for this project then register and click on CodeBin.