andrew89898 Posted January 22, 2011 Share Posted January 22, 2011 Hey, I am getting this error when I compile my main .php file. The error says it is in xmlservbase.php at line 266 Here is what line 266 looks like...... $this->onConnect($this->clients[$i]); And the only other file which has onConnect in it is Server.php and the bit with it in looks like this: function onConnect($client){ //$this->handleJoinRoom($this->getFreeRoom(), $client); } Thanks for helping, I am new too php! Quote Link to comment https://forums.phpfreaks.com/topic/225314-call-to-undefined-method-databaseonconnect/ Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 Not enough relevant code I'm afraid. Quote Link to comment https://forums.phpfreaks.com/topic/225314-call-to-undefined-method-databaseonconnect/#findComment-1163581 Share on other sites More sharing options...
andrew89898 Posted January 22, 2011 Author Share Posted January 22, 2011 How much do you need, which code do you need , whole file or what.? Quote Link to comment https://forums.phpfreaks.com/topic/225314-call-to-undefined-method-databaseonconnect/#findComment-1163583 Share on other sites More sharing options...
andrew89898 Posted January 22, 2011 Author Share Posted January 22, 2011 here is the whole function of line 266 function addClient($data = null){ if(Client::$num >= $this->config["MAX_CLIENTS"]){ socket_close(socket_accept($this->mainSocket)); return -1; } for ($i = 0; $i < $this->config["MAX_CLIENTS"]; $i++) { if (!isset($this->clients[$i])) { $this->clients[$i] = new Client(socket_accept($this->mainSocket), $this, $i); socket_set_nonblock($this->clients[$i]->sock); //socket_set_option($this->clients[$i]->sock, SOL_SOCKET, SO_LINGER, 4);//Wait 4 seconds before closing a socket(After close) socket_set_option($this->clients[$i]->sock, SOL_SOCKET, SO_REUSEADDR, 1);//Allow address reuse $this->sendPolicyFile($this->clients[$i]); 266 here.$this->onConnect($this->clients[$i]); return 0; } } } Quote Link to comment https://forums.phpfreaks.com/topic/225314-call-to-undefined-method-databaseonconnect/#findComment-1163592 Share on other sites More sharing options...
PFMaBiSmAd Posted January 22, 2011 Share Posted January 22, 2011 In the class where the above addClient() method is defined or more likely in the class that it extends, there is not a class method named onConnect(). Quote Link to comment https://forums.phpfreaks.com/topic/225314-call-to-undefined-method-databaseonconnect/#findComment-1163606 Share on other sites More sharing options...
andrew89898 Posted January 22, 2011 Author Share Posted January 22, 2011 So which code do i modify or make shall I make a onconnect class? Quote Link to comment https://forums.phpfreaks.com/topic/225314-call-to-undefined-method-databaseonconnect/#findComment-1163711 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.