Skip to content

Commit

Permalink
Added the id of the request that caused the error on the GetError event
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafa Aguilar Suarez committed Mar 25, 2014
1 parent ce46a80 commit b111746
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/php/WhatsAppEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,12 @@ function fireGetAudio(
}

function fireGetError(
$phone,
$phone,
$id,
$error
) {
$callbackEvent = function(WhatsAppEventListener $listener) use ($phone, $error) {
$listener->onGetError($phone, $error);
$callbackEvent = function(WhatsAppEventListener $listener) use ($phone, $id, $error) {
$listener->onGetError($phone, $id, $error);
};
$this->fireCallback($callbackEvent);
}
Expand Down
1 change: 1 addition & 0 deletions src/php/events/WhatsAppEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function onGetAudio(

function onGetError(
$phone, // The user phone number including the country code.
$id, // The id of the request that caused the error
$error // Array with error data for why request failed.
);

Expand Down
3 changes: 2 additions & 1 deletion src/php/events/WhatsAppEventListenerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ function onGetAudio(
) {}

function onGetError(
$phone,
$phone,
$id,
$error
) {}

Expand Down
3 changes: 2 additions & 1 deletion src/php/events/WhatsAppEventListenerProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ function onGetAudio(
}

function onGetError(
$phone,
$phone,
$id,
$error
) {
$this->handleEvent(__FUNCTION__, func_get_args());
Expand Down
1 change: 1 addition & 0 deletions src/php/whatsprot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,7 @@ protected function processInboundDataNode(ProtocolNode $node, $autoReceipt = tru
if ($node->getTag() == "iq" && $node->getAttribute('type') == "error") {
$this->eventManager()->fireGetError(
$this->phoneNumber,
$node->getAttribute( 'id' ),
$node->getChild(0)
);
}
Expand Down

0 comments on commit b111746

Please sign in to comment.