improved response handling
- btw: returning stuff in a closure doesn't make sense
This commit is contained in:
parent
fa14d96111
commit
ddc42c854f
@ -181,11 +181,16 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->decode($data);
|
$data = $this->decode($data);
|
||||||
if (is_array($data)) {
|
if (!is_array($data) || empty($data)) {
|
||||||
foreach ($data as $index => $methodResponse) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodResponse = $data[0];
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_OPENSESSION);
|
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_OPENSESSION);
|
||||||
} else if ($index <= 0) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$responseData = $methodResponse[0];
|
$responseData = $methodResponse[0];
|
||||||
$this->dedimaniaData->sessionId = $responseData['SessionId'];
|
$this->dedimaniaData->sessionId = $responseData['SessionId'];
|
||||||
if ($this->dedimaniaData->sessionId) {
|
if ($this->dedimaniaData->sessionId) {
|
||||||
@ -195,9 +200,6 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
} else {
|
} else {
|
||||||
$this->maniaControl->log("Error while opening Dedimania Connection");
|
$this->maniaControl->log("Error while opening Dedimania Connection");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, $content, true);
|
}, $content, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,13 +270,16 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
|
if (!is_array($data) || empty($data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($data)) {
|
$methodResponse = $data[0];
|
||||||
foreach ($data as $index => $methodResponse) {
|
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GETRECORDS);
|
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GETRECORDS);
|
||||||
return false;
|
return;
|
||||||
} else if ($index <= 0) {
|
}
|
||||||
|
|
||||||
$responseData = $methodResponse[0];
|
$responseData = $methodResponse[0];
|
||||||
$self->dedimaniaData->serverMaxRank = $responseData['ServerMaxRank'];
|
$self->dedimaniaData->serverMaxRank = $responseData['ServerMaxRank'];
|
||||||
|
|
||||||
@ -285,12 +290,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
foreach ($responseData['Records'] as $key => $record) {
|
foreach ($responseData['Records'] as $key => $record) {
|
||||||
$self->dedimaniaData->records[$key] = new RecordData($record);
|
$self->dedimaniaData->records[$key] = new RecordData($record);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$self->updateManialink = true;
|
$self->updateManialink = true;
|
||||||
$self->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $self->dedimaniaData->records);
|
$self->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $self->dedimaniaData->records);
|
||||||
return true;
|
|
||||||
}, $content, true);
|
}, $content, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -533,20 +535,22 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
if (is_array($data)) {
|
if (!is_array($data) || empty($data)) {
|
||||||
foreach ($data as $methodResponse) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodResponse = $data[0];
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECKSESSION);
|
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECKSESSION);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$responseData = $methodResponse[0];
|
$responseData = $methodResponse[0];
|
||||||
if (is_bool($responseData)) {
|
if (is_bool($responseData)) {
|
||||||
if (!$responseData) {
|
if (!$responseData) {
|
||||||
$self->openDedimaniaSession();
|
$self->openDedimaniaSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, $content, true);
|
}, $content, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -568,11 +572,16 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
if (is_array($data)) {
|
if (!is_array($data) || empty($data)) {
|
||||||
foreach ($data as $index => $methodResponse) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodResponse = $data[0];
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT);
|
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT);
|
||||||
} else if ($index <= 0) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$responseData = $methodResponse[0];
|
$responseData = $methodResponse[0];
|
||||||
$dediPlayer = new DedimaniaPlayer($responseData);
|
$dediPlayer = new DedimaniaPlayer($responseData);
|
||||||
$self->dedimaniaData->addPlayer($dediPlayer);
|
$self->dedimaniaData->addPlayer($dediPlayer);
|
||||||
@ -581,19 +590,11 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
if ($self->maniaControl->playerManager->getPlayerCount(false) === 1) {
|
if ($self->maniaControl->playerManager->getPlayerCount(false) === 1) {
|
||||||
$self->fetchDedimaniaRecords(true);
|
$self->fetchDedimaniaRecords(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($self->maniaControl->settingManager->getSettingValue($self, self::SETTING_WIDGET_ENABLE)) {
|
if ($self->maniaControl->settingManager->getSettingValue($self, self::SETTING_WIDGET_ENABLE)) {
|
||||||
$manialink = $self->buildManialink();
|
$manialink = $self->buildManialink();
|
||||||
$self->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
|
$self->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!$data) {
|
|
||||||
trigger_error('XmlRpc Error.');
|
|
||||||
var_dump($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, $content, true);
|
}, $content, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,19 +620,14 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
if (is_array($data)) {
|
if (!is_array($data) || empty($data)) {
|
||||||
foreach ($data as $methodResponse) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodResponse = $data[0];
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT);
|
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!$data) {
|
|
||||||
trigger_error('XmlRpc Error.');
|
|
||||||
var_dump($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, $content, true);
|
}, $content, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,22 +689,20 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
if (is_array($data)) {
|
if (!is_array($data) || empty($data)) {
|
||||||
foreach ($data as $index => $methodResponse) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodResponse = $data[0];
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SETCHALLENGETIMES);
|
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SETCHALLENGETIMES);
|
||||||
} else {
|
return;
|
||||||
if ($index <= 0) {
|
}
|
||||||
|
|
||||||
// Called method response
|
// Called method response
|
||||||
$responseData = $methodResponse[0];
|
if (!$methodResponse[0]) {
|
||||||
if (!$responseData) {
|
|
||||||
trigger_error("Records Plugin: Submitting dedimania records failed.");
|
trigger_error("Records Plugin: Submitting dedimania records failed.");
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, $content, false);
|
}, $content, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,19 +728,14 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $self->decode($data);
|
$data = $self->decode($data);
|
||||||
if (is_array($data)) {
|
if (!is_array($data) || empty($data)) {
|
||||||
foreach ($data as $methodResponse) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$methodResponse = $data[0];
|
||||||
if (xmlrpc_is_fault($methodResponse)) {
|
if (xmlrpc_is_fault($methodResponse)) {
|
||||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATESERVERPLAYERS);
|
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATESERVERPLAYERS);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!$data) {
|
|
||||||
trigger_error('XmlRpc Error.');
|
|
||||||
var_dump($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}, $content, true);
|
}, $content, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user