2.23.2013

Skype App2App notes


Want to share several notes that I did during development of communication protocol for my robot using Skype App2App.

Lets assume we have 3 skypes running (or skypekits):

  1. UserA logged on PC1
  2. UserA logged on PC2 (yes, same user, but on different machine)
  3. UserB logged on PC3

All accounts create application TestApp1. And now when:

Action Streams Datagrams Comments
UserA - PC1 UserA - PC2 UserB UserA - PC1 UserA - PC2 UserB
UserA-PC1 connects to UserB UserB:1 - UserA:1 - - - -
UserA-PC1 disconnects UserB - - - - - - The same result will be in opposite case, when UserB disconnects UserA-PC1.
UserA-PC1 connects to UserB again UserB:2 - UserA:2 - - - Numeration of streams increasing.
Restart skype on UserA-PC1 and connect to UserB again UserB:1 - UserA:3 - - - Numeration of streams done on each client app independently.
UserA-PC2 connects to UserB UserB:1 UserB:1 UserA:2 UserA:3 - - - -
UserB sends datagram to UserA-PC1 UserB:1 UserB:1 UserA:2 UserA:3 data - - Datagram sent per stream.
UserB sends datagram to UserA-PC2 UserB:1 UserB:1 UserA:2 UserA:3 - data - -
UserB goes offline (by user action) UserB:1 UserB:1 - - - - Need to clear streams on UserA sides.
UserB goes online and reconnects to UserA UserB:1 UserB:2 UserB:1 UserB:2 UserA:4 UserA:5 - - - Application and numerations preserved. UserB:1 streams exists but not functioning.
UserB deletes application without disconnecting UserB:1 UserB:2 UserB:1 UserB:2 - - - - Now we have 2x2 orphane streams.

That's it, now it is straightforward that when skype gives you array of streams you should use all of them for communication and send messages in cycle to each stream. There can be mix of orphane and live streams, and if you take from array only first it could be not functioning in multiple reconnection scenarios.

10 comments:

  1. Hello! I am working with C# using Skype4Com.
    Now i try to create app2app. But there is one problem: application.connect(name,true) doesn`t work, and there is no any exceptions. It looks like it works. But when i check application.connectingusers it returns 0. Also any datagrams are sending. Help please

    ReplyDelete
  2. If it is possible contact with me isaevdan@gmail.com

    ReplyDelete
  3. Hi, I noticed two strange things:
    1. why do you use user name as application name? If you use CurrentUserHandle on remote side too, it will be different (will contain skype account of remote user) and application names will not match. Try with some constant value on both sides.
    2. I saw that you call Attach() on apiAttachAvailable that is good, but will work only if your app was started before Skype. If you have another place with Attach(), not in event handler, that is good.
    3. Also, it could be something wrong on remote side. Did you test remote side with Trace.exe?
    To understand what is going on, try to log info about sent and received commands using Command, Reply, Error events on both sides and send log to me.

    ReplyDelete
  4. 1)The main idea ia that many users will connect to one host. Where code that i sent you is code of clients. The host will only log information sent. And to know which user has sent information i use application name
    2)Here is Host code(PS Attach works because it waitin for skype). Host receives inforamtion from all user/applications.
    public Form1()
    {
    InitializeComponent();
    skype = new Skype();
    ((_ISkypeEvents_Event)skype).AttachmentStatus += new _ISkypeEvents_AttachmentStatusEventHandler(Form1_AttachmentStatus);
    skype.ApplicationDatagram += new _ISkypeEvents_ApplicationDatagramEventHandler(skype_ApplicationDatagram);
    Attaching(skype);
    }

    void skype_ApplicationDatagram(SKYPE4COMLib.Application pApp, ApplicationStream pStream, string Text)
    {
    Log(Text);
    }

    private void Attaching(Skype skype)
    {
    while (!skype.Client.IsRunning)
    {
    System.Threading.Thread.Sleep(100);
    }
    skype.Attach();
    }
    3) The problem is that i suppose that client doesn`t coonect at all. I tries to lof information on client side about clientconnecttings and clientconnecable before and after application connect, and anything is changed. I didn`t work with trace.exe before, but i try to start. As i understand i helps to log info about sent and received commands using Command, Reply, Error events on both sides?
    PS Thank you for your reply!!!

    ReplyDelete
  5. Good morning,
    look, when using app2app first thing both sides should do (after attachment) is creating application with exactly same name. As I can see, there is no application created on host side, so host will not react on connection request. If you will try to play your scenario using trace.exe on both sides you will see that. And since appname should be the same, it is better to use some constant string for it. To differentiate users you can use stream name, it always has format like skypename:id. Look at examples here: http://dev.skype.com/desktop-api-reference#COMMAND_AP2AP_EXAMPLE

    ReplyDelete
  6. Also, call to Attach() will be blocked by default (look at second default parameter in signature). So not sure if you need waiting loop.

    ReplyDelete
  7. About logging - trace.exe gives you an ability to play with protocol directly. It will not log events related to your .net application. You should do it yourself by attaching to events listed above.

    ReplyDelete
  8. Thank you very mush for your help. I didn`t know that both client should create applications. Now i am sure i`ll solve my problem

    ReplyDelete
  9. No problem, feel free to ask if more questions arise.

    ReplyDelete
  10. Hey. please help me..my skype account just been hacked ,,and they changed everything ..this my skype because i lost my mobile phone .the one steal my mobile the one also hacked my fb account.please help me.thanks visit more info Skype Support and Call +1-800-231-4635 USA (Toll Free).

    ReplyDelete