diff --git a/examples/ajaxDemo/socket.php b/examples/ajaxDemo/socket.php index b05c108c..08046217 100644 --- a/examples/ajaxDemo/socket.php +++ b/examples/ajaxDemo/socket.php @@ -98,7 +98,7 @@ function onGetImage($mynumber, $from, $id, $type, $t, $name, $size, $url, $file, //TODO: presense handling (online/offline/typing/last seen) while (running($time)) { - $w->pollMessages(); + while($w->pollMessage()); running($time); //check again if timestamp has been updated //check for outbound messages to send: diff --git a/examples/bulk.php b/examples/bulk.php index a22a111f..1f37438f 100644 --- a/examples/bulk.php +++ b/examples/bulk.php @@ -61,7 +61,7 @@ public function Login() $this->wa->loginWithPassword($this->password); $this->wa->sendClientConfig(); $this->wa->sendGetServerProperties(); - $this->wa->pollMessages(); + while($this->wa->pollMessage()); echo "Ready for work!
"; } @@ -123,7 +123,7 @@ public function SendBroadcast($targets, $message) } echo "Sending broadcast... "; $this->wa->sendBroadcastMessage($targets, $message); - $this->wa->pollMessages(); + $this->wa->pollMessage(); echo "done!
"; } @@ -137,10 +137,10 @@ public function SendBulk($targets, $message) foreach($targets as $target) { $this->wa->sendPresenceSubscription($target); - $this->wa->pollMessages(); + $this->wa->pollMessage(); $this->wa->sendMessageComposing($target); sleep(1); - $this->wa->pollMessages(); + $this->wa->pollMessage(); $this->wa->sendMessagePaused($target); static::$sendLock = true; echo "Sending message from " . $this->username . " to $target... "; diff --git a/examples/contactsync.php b/examples/contactsync.php index d3b9bb5b..1f3851fe 100644 --- a/examples/contactsync.php +++ b/examples/contactsync.php @@ -53,5 +53,5 @@ function onSyncResult($result) //wait for response while(true) { - $wa->pollMessages(); + $wa->pollMessage(); } \ No newline at end of file diff --git a/examples/exampleFunctional.php b/examples/exampleFunctional.php index f24588c2..9a060592 100644 --- a/examples/exampleFunctional.php +++ b/examples/exampleFunctional.php @@ -102,7 +102,7 @@ function onPresenceReceived($username, $from, $type) $w->sendMessage($target, "Guess the number :)"); $w->sendMessage($target, "Sent from WhatsApi at " . date('H:i')); -$w->pollMessages(); +while($w->pollMessage()); /** * You can create a ProcessNode class (or whatever name you want) that has a process($node) function @@ -115,7 +115,7 @@ function onPresenceReceived($username, $from, $type) echo "\n\nYou can also write and send messages to $target (interactive conversation)\n\n> "; while (1) { - $w->pollMessages(); + $w->pollMessage(); $msgs = $w->getMessages(); foreach ($msgs as $m) { # process inbound messages diff --git a/src/whatsprot.class.php b/src/whatsprot.class.php index f02da44b..fa68c27f 100644 --- a/src/whatsprot.class.php +++ b/src/whatsprot.class.php @@ -475,19 +475,6 @@ public function loginWithPassword($password) $this->doLogin(); } - /** - * Pull from the socket, and place incoming messages in the message queue. - */ - public function pollMessages($autoReceipt = true) - { - $stanza = $this->readStanza(); - while($stanza) - { - $this->processInboundData($stanza, $autoReceipt); - $stanza = $this->readStanza(); - } - } - /** * Fetch a single message node * @param bool $autoReceipt @@ -1418,7 +1405,7 @@ public function waitForMessageReceipt() { $received = false; do { - $this->pollMessages(); + $this->pollMessage(); $msgs = $this->getMessages(); foreach ($msgs as $m) { // Process inbound messages. diff --git a/tests/whatsapp.php b/tests/whatsapp.php index 45fb6030..712c41f7 100644 --- a/tests/whatsapp.php +++ b/tests/whatsapp.php @@ -49,7 +49,7 @@ function fgets_u($pStdn) echo "\n[] Interactive conversation with $dst:\n"; stream_set_timeout(STDIN,1); while (TRUE) { - $wa->pollMessages(); + while($wa->pollMessage()); $buff = $wa->getMessages(); if (!empty($buff)) { print_r($buff); @@ -84,7 +84,7 @@ function fgets_u($pStdn) if ($_SERVER['argv'][1] == "-l") { echo "\n[] Listen mode:\n"; while (TRUE) { - $wa->pollMessages(); + $wa->pollMessage(); $data = $wa->getMessages(); if(!empty($data)) print_r($data); sleep(1);