Help - Search - Members - Calendar
Full Version: api-commands with Skype4Com
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
Dr.O
Hello again,
my application is growing wink.png but there are a couple of questions left where I need some help. I start today with some questions about the "Command" command of Skype4Com.dll for Api-calls. My application is written in c#.

First Question is to help me understanding how it works. As shown in help file the ICommand interface provides me these methods:
CODE

Properties
LONG  Id [get, set]
  This command queries/sets a command ID.

LONG  Timeout [get, set]
  This command queries/sets the wait timeout in milliseconds.

VARIANT_BOOL  Blocking [get, set]
  This command queries/sets if blocking is set.

BSTR  Command [get, set]
  This command queries/sets the command text.

BSTR  Reply [get, set]
  This command queries/sets the reply text.

BSTR  Expected [get, set]
  This command queries/sets the expected reply text.


So I made this in my code:
CODE

private Command sCommand;


next a Command EventHandler (but I don't know if I need it???)
CODE

skype.Command += new _ISkypeEvents_CommandEventHandler(skype_Command);


What I want to do:
set chatroles and privileges in a public chat via my application!
from the api-doc:
CODE
ALTER CHATMEMBER SETROLETO

This command enables chat administrators (chat CREATORS AND MASTERS) to set privilege levels (roles) for other chat members.

Syntax:

    *

      -> ALTER CHATMEMBER <id> SETROLETO CREATOR|MASTER|HELPER|USER|LISTENER

Refer to

    *

      Chat roles section for more information on different roles. Note that you cannot demote a user to LISTENER role when the chat is already in ready-only mode (USERS_ARE_LISTENERS chat option).
    *

      ALTER CHATMEMBER CANSETROLETO command for how to determine if it is possible to change the role of any given chat member.

Example:

-> GET CHAT #anappo/$anappo3;5f7cdbdd32dc731c MEMBEROBJECTS
<- CHAT #anappo/$anappo3;5f7cdbdd32dc731c MEMBEROBJECTS 1846, 2227, 2495
-> GET CHATMEMBER 2495 IDENTITY
<- CHATMEMBER 2495 IDENTITY anappo2
-> GET CHATMEMBER 2495 ROLE
<- CHATMEMBER 2495 ROLE HELPER
-> ALTER CHATMEMBER 2495 SETROLETO USER
<- ALTER CHATMEMBER SETROLETO
<- MESSAGE 2620 STATUS SENDING
<- CHATMEMBER 2495 ROLE USER

Version

    * Protocol 7 (API version 3.0)


Now, please can someone give me an example how to build a valid command. Maybe lets start with setting a user's privileg to "listener"
Avo Nappo
Not sure about C# syntax but in Delphi handling of commands goes something like this:

CODE

Var Skype : TSkype; // This example assumes Skype object is created and attached

Procedure OpenUserInfo(Sender: TObject);

Var
Cmd     : ICommand;
CmdID  : Integer;

Begin
// CmdID should be non-0
CmdID := 12345;
Cmd := Skype.Command[CmdID, 'OPEN USERINFO echo123', '', True, 5000];

Try
  Skype.SendCommand(Cmd);
Except
  // Error handling goes here..
End;

// If Cmd was executed properly, Cmd.Reply will now contain the response string
End;
Dr.O
is cmdID a random number?
Avo Nappo
> is cmdID a random number?

In that example it pretty much was, yes smile.png

The purpose of the ID property in ICommand structure is for Skype4Com to match commands sent to Skype from your application with responses Skype sends back. Basically it is Skype4Com's implementation of "Command Identifiers" in API protocol, described here:

https://developer.skype.com/Docs/ApiDoc/Command_identifiers

In your own application, it makes sense to provide a mechanism to ensure that all your command identifiers are unique. Something like having a global CmdIDCounter variable, and a function that increments that counter each time before you use it to make a new ICommand.
Dr.O
ok basically I understand your delphi example, but I cannot get it worked in c# code - so if someone have on plz post it wink.png thx a lot
Dr.O
nobody knows?

this I have tried but doesn't work:
CODE

int cID = 2354564;
sCommand.Id = cID;
sCommand.Timeout = 5000;
sCommand.Command = "ALTER CHATMEMBER xxx SETROLETO LISTENER";

try
{
    skype.SendCommand(sCommand);
}
catch
{
        //       ;
        //        //throw;
}


xxx = someone's skype-username
My program is Moderator in the chat-channel
TheUberOverlord
QUOTE(Dr.O @ Fri May 18 2007, 09:48) [snapback]396496[/snapback]

nobody knows?

this I have tried but doesn't work:
CODE

int cID = 2354564;
sCommand.Id = cID;
sCommand.Timeout = 5000;
sCommand.Command = "ALTER CHATMEMBER xxx SETROLETO LISTENER";

try
{
    skype.SendCommand(sCommand);
}
catch
{
        //;
        //        //throw;
}


xxx = someone's skype-username
My program is Moderator in the chat-channel


Have you tried something like this?

http://forum.skype.com/index.php?showtopic...&hl=command

Also please look here:

http://forum.skype.com/index.php?s=&sh...st&p=403577

Also. You don't need any event handlers for the command request but for the Reply and any possible Errors, you may need a event handler depending on how you set blocking for the Command Request.

Look for the ISkype Reply and Error Event Handlers. You will want both based on your command Blocking setting of true or false, so that you can get command errors ("You might have a badly formatted command") and Replies ("If Blocking is false then the Reply will be returned in the Command.Reply area vs as a Event buffer, but it is ALWAYS best to have an Error event handler when using the command interface in Skype4COM in the event that the original String of teh Command Request is not valid.

The BEST Example of using the Command interface using one line vs multiple lines is Command.vbs located in the Skype4COM.chm help file located in the Download .ZIP of Skype4COM lib

https://developer.skype.com/Docs/Skype4COM

Examples:

CODE


00010 '// Skype4COM can send two types of command; blocking commands and non-blocking commands. Blocking is defined as a Boolean variant of the command object and the default value is False, non-blocking. A blocking command awaits a reply before continuing. A non-blocking command does not require a reply.
00011
00012 '// Send the following non-blocking commands:
00013 oSkype.SendCommand(oSkype.Command(0, "FOCUS"))
00014 oSkype.SendCommand(oSkype.Command(1, "GET AUDIO_IN", "AUDIO_IN"))
00015 oSkype.SendCommand(oSkype.Command(2, "GET AUDIO_OUT", "AUDIO_OUT"))
00016 WScript.Sleep(1000)
00017
00018 '// Send the following blocking commands (note the True (blocking) variant for each command):
00019 oSkype.SendCommand(oSkype.Command(3, "GET CURRENTUSERHANDLE", "CURRENTUSERHANDLE", True))
00020 oSkype.SendCommand(oSkype.Command(4, "GET USER echo123 FULLNAME", "USER echo123 FULLNAME", True))
00021 oSkype.SendCommand(oSkype.Command(5, "GET USER echo123 DISPLAYNAME", "USER echo123 DISPLAYNAME", True))
00022 oSkype.SendCommand(oSkype.Command(6, "GET USER echo123 COUNTRY", "USER echo123 COUNTRY", True))
00023 WScript.Sleep(1000)
00024
00025 '//As with command objects, search commands can be defined as blocking or non-blocking, and the default value is False, non-blocking. A blocking search requires a response before activities continue. Following is a blocking search (note the True (blocking) variant:
00026 Set oBlockingSearch = oSkype.Command(8888, "SEARCH USERS echo123", "USERS ", True)
00027 oSkype.SendCommand(oBlockingSearch)
00028 WScript.Echo "Search Result:" & oBlockingSearch.Reply
00029
00030 '//A non-blocking search does not require a response:
00031 Set oSearchCommand = oSkype.Command(9999, "SEARCH USERS john doe", "USERS ")
00032 oSkype.SendCommand(oSearchCommand)
00033
00034 WScript.Echo "Sleeping ..."
00035 WScript.Sleep(30000)



Of course there is nothing wrong using the long hand method as well.


Command _user_waiting = new SKYPE4COMLib.CommandClass();
_user_waiting.Command = "SEARCH USERSWAITINGMYAUTHORIZATION";
_user_waiting.Blocking = false;
_user_waiting.Id = this.commandId++;
skype.SendCommand(_user_waiting);

In the above case, you would want to be using the _ISkypeEvents Reply event handler so that you can process and parse Response(s) in the event handler, as they arrive, and not make your application wait on the response(s).

Again, personally, if I was going to use the Skype4COM command interface, I also would use the Error Event handler as well. So that if my Command String was messed up and bad, I would also receive the error for that there as well.


Hope This makes sense?
torsti181279

referring to https://developer.skype.com/Docs/ApiDoc/ALT...EMBER_SETROLETO
ALTER CHATMEMBER <id> SETROLETO CREATOR|MASTER|HELPER|USER|LISTENER

what is the <id> - the handle ?
TheUberOverlord
QUOTE(torsti181279 @ Fri Nov 30 2007, 09:28) [snapback]469923[/snapback]

referring to https://developer.skype.com/Docs/ApiDoc/ALT...EMBER_SETROLETO
ALTER CHATMEMBER <id> SETROLETO CREATOR|MASTER|HELPER|USER|LISTENER

what is the <id> - the handle ?


No It is a MemberObject. I quote:

"provides list of CHATMEMBER object IDs that represent chat participants."

https://developer.skype.com/Docs/ApiDoc/GET...T_MEMBEROBJECTS

-> GET CHAT #anappo/$anappo3;5f7cdbdd32dc731c MEMBEROBJECTS
"<- CHAT #anappo/$anappo3;5f7cdbdd32dc731c MEMBEROBJECTS 1846, 2227, 2495"

Here is some more information:

https://developer.skype.com/Docs/ApiDoc/ALT...ER_CANSETROLETO
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.