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; }