Thursday, March 17, 2011

Skype4Java API

Along the project, I took the mission of making the Skype4Java project more reliable. I found that the Skype API under linux is very tricky and doesn't always works as expected. I found several problems.

First, after running for some time, the X-11 Atom "_SKYPE_INSTANCE" just disappears. After that, the skype4java doesn't be able to attach to the running skype and, of course, skype2gmail stops working.

Well, I changed the code and used a workaround, so the native library is now able to find the skype window used by the API under linux even when the atom is gone.

The second problem I faced was mixed responses. Sometimes when two messages are sent through the skype api "very fast", the former message's response was truncated and the later's message response was concatenated. There's no need to say how troubling this was. The application keeps waiting for both responses and got stuck forever.

Fixed the concatenation problem, which was a bug in the native library, but I still couldn't figure out why the first message's response was truncated. I worked around this problem changing the way the java api works. Instead of "ping ponging" after every request (to keep alive), when the timeout comes I changed to retry the request. This made the library much more reliable and it seems it works all the time (except when the api fails to connect to skype, which is happening sometimes).

Sometime in the future I'll have to address mainly in the following problems with the Skype4Java:

- Sometimes (not very often), the application simply doesn't connect. It seems the application sends the request to skype, but there's no response. It always work to retry just after canceling the application. I suppose I can fix by retrying the connection after a short timeout.

- I intend to figure why the native library receives partial messages sometimes. For now, after the connection is established, the application always works to the end, so the workaround seems to be working fine, but it might be the reason the connection fails sometimes. Also, the application will certainly work faster when this problem is fixed, since the requests won't have to be retried as often.


Oh yeah, this development is getting more interesting every day

1 comment:

  1. Hi Gabriel, is there any way i can inject audio into a skype call using Skype4java?

    ReplyDelete