public function __construct($id) { parent::__construct(); $this->code = 500; $this->_id = $id; $args = func_get_args(); array_shift($args); $this->_args = $args; IMuTrace::write(2, 'exception: %s', $this->__toString()); }
public function request($request) { $this->connect(); if ($this->_close != null) { $request['close'] = $this->_close; } if ($this->_context != null) { $request['context'] = $this->_context; } if ($this->suspend != null) { $request['suspend'] = $this->_suspend; } $this->_stream->put($request); $response = $this->_stream->get(); $type = gettype($response); if ($type != 'array') { throw new IMuException('SessionResponse', $type); } if (array_key_exists('context', $response)) { $this->_context = $response['context']; } if (array_key_exists('reconnect', $response)) { $this->_port = $response['reconnect']; } $disconnect = false; if ($this->_close != null) { $disconnect = $this->_close; } if ($disconnect) { $this->disconnect(); } $status = $response['status']; if ($status == 'error') { IMuTrace::write(2, 'server error'); $id = 'SessionServerError'; if (array_key_exists('error', $response)) { $id = $response['error']; } else { if (array_key_exists('id', $response)) { $id = $response['id']; } } $e = new IMuException($id); if (array_key_exists('args', $response)) { $e->setArgs($response['args']); } if (array_key_exists('code', $response)) { $e->setCode($response['code']); } IMuTrace::write(2, 'throwing exception %s', $e->__toString()); throw $e; } return $response; }
public static function setPrefix($prefix) { self::$_prefix = $prefix; }
/** * @details Determines the full request URL, loads all GET & POST parameters * to a common variable and loads config files relative to #$dir param. * * @param string $dir * The base web service directory. * @see loadConfig() */ public function __construct($dir) { $this->dir = $dir; $this->url = strtolower(preg_replace('/\\/.*$/', '', $_SERVER['SERVER_PROTOCOL'])); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $this->url .= 's'; } $this->url .= '://' . $_SERVER['SERVER_NAME']; if ($_SERVER['SERVER_PORT'] != 80) { $this->url .= ':' . $_SERVER['SERVER_PORT']; } $this->url .= $_SERVER['REQUEST_URI']; $this->params = array(); global $_GET; foreach ($_GET as $name => $value) { $this->params[$name] = $value; } global $_POST; foreach ($_POST as $name => $value) { $this->params[$name] = $value; } /* Configure */ $config = array(); /* ... defaults */ $config['host'] = IMuSession::getDefaultHost(); $config['port'] = IMuSession::getDefaultPort(); /* ... service-specific */ $this->loadConfig($config); $this->config = $config; if (array_key_exists('trace-file', $this->config)) { IMuTrace::setFile($this->config['trace-file']); } if (array_key_exists('trace-level', $this->config)) { IMuTrace::setLevel($this->config['trace-level']); } }