Scordo/TS3QueryLib.Net

Listener before send any query

Closed this issue · 3 comments

Hello there, this is more sort of a question. Is the any method / delegation / way that before send a command it lists?

for example

QueryDispatcher.BeforeSendQuery += QueryDispatcher_BeforeSendQuery;
private void QueryDispatcher_BeforeSendQuery( required arguments)
    {
        if(x == 1) block commands and don't query them otherwise execute
    }

If it's not possible, could be implemented?

Hi,

there is no function like this.
I dont see a valid usecase for it.
Can you give me an example?

Regards,
Scordo

Hello Scordo, it's really useful when you are integrating with 3rd party software / library where you have things to block.

For example, I'm using your library to control the teamspeak inside of a game. I have player's that may want to not be moved and use the ts3 freely.

With this method It will be possible to block the Query's from people that don't want to be disturbed with only a line of code from being moved, other wise I will need to add the same lane over all methods where I use QueryRunners.

private void QueryDispatcher_BeforeSendQuery(QueryCommand / Method executed)
    {
        if(ClientDontWanteToBeDisturbed) block commands and don't query.
    }

Hi,

I've added a property where you can set a function which is evaluated before sending a command.

Example:

QueryRunner.SendCommandValidationPredicate = (command, queryRunner) => !"version".Equals(command.Name, StringComparison.InvariantCultureIgnoreCase);

This would allow every command to be sent, except the version-command.
If a command was not sent, the returned response is Erroneous and has a ErrorId=256 and ErrorMessage="command not sent".

Regards,
Scordo