| Skype API For Mac |
| Sunday, 06 April 2008 15:17 |
|
One easy way to implement communications between two applications over the internet is to piggy-back onto an instant messenger. Skype allows you to do this (through its AP2AP protocol) as well as access a whole load of other features through its API. This can be done on the Mac platform through either AppleScript calls (this is easiest but lacks any way of allowing Skype to send updates of events asynchronously) or through the Skype framework. This REALbasic code provides access to the functions and call-back events in the framework, and also implements an example class to illustrate using the Skype API to access the user's buddy list and online status information. The Skype framework must be downloaded from Skype's developer site here, and should be either bundled into the completed app or installed in the appropriate "Frameworks" folder. The commands and responses used in the command strings are documented in the Skype API Reference. The Skype project file (see attachments) consists of the following elements: Module – SkypeThis module contains the code for interfacing with Skype through the framework. This consists of the following public classes: Initialise - This sets up the Skype connection object or delegate. Accepts a parameter of the application name as a string, and returns nothing. The name you specify is the one that the Skype application will use to authorise against your connection. You should not include version information.
Interface – SkypeMessageReceiverThis class interface implements four methods called by asynchronous messages returned from Skype. All classes which use the Skype API should implement this interface and should be registered with the Skype module using the AddListener method. The methods defined by the interface are:
Example Class - SkypeTestThis class simply implements a single event handler which is passes on any notification messages from the Skype API. Example Class - Skype User ListThis class uses the API to build and maintain a dictionary (called Users) which contains a list of all the user's Skype contacts, together with their full name, display name and online status. These values are stored as dictionaries within the main dictionary, with the user id as the key. The other keys are "FULLNAME", "DISPLAYNAME" and "ONLINESTATUS". This is kept updated using the Skype notifications, and other dictionary values may be added by these notifications (explore this by browsing using the debugger). Window - Window1This window uses the SkypeTest class to display the notification messages sent by the Skype API. Skype messages can also be sent with the responses being included in the edit field. Note the Open and Close methods which are used for attaching and detaching to the Skype API. |