Help - Search - Members - Calendar
Full Version: Non-Blocking Skype4COM Commands
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
carcass_
Would somebody tell me why the following code does not return a "PONG"?

Thanks!

CODE
using System;

using System.Threading;

using SKYPE4COMLib;



namespace Test

{



/// <summary>

/// Summary description for Class1.

/// </summary>

class TestAPIApp

{

 private static void OnCommand(Command CommandReply) {

  Console.WriteLine("Command: " + CommandReply.Command);

 }



 private static void OnReply(Command CommandReply) {

  Console.WriteLine("Reply: " + CommandReply.Reply);

 }



 [STAThread]

 static void Main(string[] args)

 {

  Console.WriteLine ("Initializing Library");

  SKYPE4COMLib.SkypeClass objSkype = new SkypeClass();

  objSkype.Reply += new _ISkypeEvents_ReplyEventHandler(OnReply);

  objSkype._ISkypeEvents_Event_Command += new _ISkypeEvents_CommandEventHandler(OnCommand);



  Console.WriteLine("Sending PING");

  CommandClass objCmd = new CommandClass();

  objCmd.Blocking = false;

  objCmd.Command = "PING";

  objCmd.Id = 1;

  objSkype.SendCommand(objCmd);



  Console.WriteLine("Waiting for response, press Enter to quit");

  while(Console.In.Peek() == 0) {

   Thread.Sleep(10);

  }

  Console.In.Read();

 }

}

}


Results:

[quote]Initializing Library
Sending PING
Command: PROTOCOL 5
Reply: CONNSTATUS ONLINE
Reply: CURRENTUSERHANDLE jasonterando
Reply: USERSTATUS ONLINE
Reply: PROTOCOL 5
Command: GET SKYPEVERSION
Reply: SKYPEVERSION 2.5.0.75
Command: PING
Waiting for response, press Enter to quit[/quote]

Wait for a couple of minutes, no response is returned. Other Skype response notifications appear to be received properly, and my PING command appears to be sent, so I'm stuck...
TheUberOverlord
Did some testing using VBScript on Ping Pong, it works with blocking and non-blocking, but just for fun did you try blocking set to TRUE?

objCmd.Blocking = true;

Could you let us know what happens?

Just a theory I have.

This may or may NOT be related:

http://forum.skype.com/viewtopic.php?t=538...highlight=cache

Could you let us know what you found after testing
andreskaasik_
Try to change the [STAThread] to [MTAThread], maybe this helps.
carcass_
Thanks Andre, the threading model was the trick!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.