*/
protected function checkResponseStatus(HTTP_Request2_Response $resp)
{
- $this->log($resp, 3);
-
$nStatus = $resp->getStatus();
$this->log($nStatus . ' ' . $resp->getReasonPhrase(), 1);
if (intval($nStatus / 100) == 2) {
public function log($msg, $level = 1)
{
if ($this->verbosity >= $level) {
- if ($msg instanceof HTTP_Request2_Response) {
- echo "HTTP Response:\n";
- echo $msg->getStatus() . ' ' . $msg->getReasonPhrase() . "\n";
- echo 'Header: ';
- var_export($msg->getHeader());
- echo $msg->getBody() . "\n----\n";
- return;
- }
echo $msg . "\n";
}
}
'GPRS_MSG.WWBEAR_GPRS' => 'GPRS',
'GPRS_MSG.WWBEAR_UMTS' => 'UMTS',
'GPRS_MSG.None' => null,
+ 'GPRS_MSG.FAIR' => 'fair',
'GPRS_MSG.GOOD' => 'good',
'GPRS_MSG.EXCELLENT' => 'excellent',
+ 'GPRS_MSG.NOSIGNAL' => 'no signal',
'GPRS_MSG.CTIME' => 'connection time',
'GPRS_MSG.CFW' => 'card firmware',
'GPRS_MSG.CMOD' => 'card model',
class Wrt3g_RequestObserver implements SplObserver
{
protected $wrt3g;
+ protected static $supportedEvents = array(
+ 'connect', 'sentHeaders', 'receivedBody', 'disconnect'
+ );
/**
* Create new instance
public function update(SplSubject $subject)
{
$event = $subject->getLastEvent();
+ if (!in_array($event['name'], self::$supportedEvents)) {
+ return;
+ }
+
+ if ($event['name'] == 'receivedBody') {
+ $resp = $event['data'];
+ $event['data']
+ = $resp->getStatus() . ' ' . $resp->getReasonPhrase() . "\n"
+ . 'Header: ' . var_export($resp->getHeader(), true)
+ . $resp->getBody() . "\n----\n";
+ }
+
$this->wrt3g->log(
- 'event: ' . $event['name'] . "\n"
+ 'event: ' . $event['name'] . ', '
. 'data: ' . $event['data'],
3
);