PHP framework loops connection for some reason

mardi 8 décembre 2015

A goodday to all of you.
I am a developer at RoleplayUnited (gaming clan) and I am trying to develop a TS3 bot.

I am using the PHP framework.
What I am trying to do is make the bot respond to any .command sent through a textmessage (server, channel or private).
I am able to receive the .command server-side and I am able to sent a response to the invoker.

The problem is this:

After I respond to the invoker, the bot opens up an infinite amount of ServerQuery connections up until the point that the server is full (server maxclient reached). What I want the bot to do is to go "back to sleep" and listen for other commands after calling the processCommand (onTextMessage) function.

This is all working:
PHP Code:

$ts3_connection = new Ts3($pdo); /* my own TS3 class that holds connection variables */
$ts3 TeamSpeak3::factory($ts3_connection->connect);
$ts3->notifyRegister("textchannel");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", array($ts3_connection"processCommand"));
while(
1) { $ts3->getAdapter()->wait(); }
$ts3->logout(); 

This is the method that processes the command. I suspect that something is wrong here:
PHP Code:

function processCommand(TeamSpeak3_Adapter_ServerQuery_Event $eventTeamSpeak3_Node_Host $host) {
    
$ts3 TeamSpeak3::factory($ts3_connection->connect);
    
/* Ping test */
    
if(in_array($event["msg"], [".ping"])) {
        
$ts3->clientGetByUid($event["invokeruid"])->message("Pong!");
    }
    return 
0;


I would be most thankful for any help that points me in the right direction.
PHP framework loops connection for some reason

0 commentaires:

Enregistrer un commentaire