private function callback($command, $name, $pattern, $request_info, $request, $timeout, $priority, $trans_id, $pid)
{
if ($this->request_timeout_adjustment) {
$this->request_timer = microtime(true);
$this->request_timeout = $timeout;
}
if (!isset($this->callbacks[$pattern])) {
$function = array($this, 'null_response');
} else {
$function_queue =& $this->callbacks[$pattern];
$function = array_shift($function_queue);
$function_queue[] = $function;
}
switch ($command) {
case MESSAGE_SEND_ASYNC:
try {
$response = call_user_func($function, API::$ASYNC, $name, $pattern, $request_info, $request, $timeout, $priority, $trans_id, $pid);
if (is_array($response)) {
assert(count($response) == 2);
$response_info = $response[0];
$response = $response[1];
if (!is_string($response_info)) {
$response_info = '';
}
} else {
$response_info = '';
}
if (!is_string($response)) {
$response = '';
}
} catch (InvalidInputException $e) {
throw $e;
} catch (MessageDecodingException $e) {
throw $e;
} catch (TerminateException $e) {
throw $e;
} catch (ReturnAsyncException $e) {
return;
} catch (ForwardAsyncException $e) {
return;
} catch (ReturnSyncException $e) {
echo "{$e->getMessage()}\n{$e}\n";
assert(false);
return;
} catch (ForwardSyncException $e) {
echo "{$e->getMessage()}\n{$e}\n";
assert(false);
return;
} catch (\Exception $e) {
echo "{$e->getMessage()}\n{$e}\n";
$response_info = '';
$response = '';
}
try {
$this->return_async($name, $pattern, $response_info, $response, $timeout, $trans_id, $pid);
} catch (ReturnAsyncException $e) {
}
return;
case MESSAGE_SEND_SYNC:
try {
$response = call_user_func($function, API::$SYNC, $name, $pattern, $request_info, $request, $timeout, $priority, $trans_id, $pid);
if (is_array($response)) {
assert(count($response) == 2);
$response_info = $response[0];
$response = $response[1];
if (!is_string($response_info)) {
$response_info = '';
}
} else {
$response_info = '';
}
if (!is_string($response)) {
$response = '';
}
} catch (InvalidInputException $e) {
throw $e;
} catch (MessageDecodingException $e) {
throw $e;
} catch (TerminateException $e) {
throw $e;
} catch (ReturnSyncException $e) {
return;
} catch (ForwardSyncException $e) {
return;
} catch (ReturnAsyncException $e) {
echo "{$e->getMessage()}\n{$e}\n";
assert(false);
return;
} catch (ForwardAsyncException $e) {
echo "{$e->getMessage()}\n{$e}\n";
assert(false);
return;
} catch (\Exception $e) {
echo "{$e->getMessage()}\n{$e}\n";
$response_info = '';
$response = '';
}
try {
$this->return_sync($name, $pattern, $response_info, $response, $timeout, $trans_id, $pid);
} catch (ReturnSyncException $e) {
}
return;
default:
throw new MessageDecodingException();
}
}