space fixes, added timeout to connect(), general fixes
git-svn-id: svn://netflint.net/xmpphp@39 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
parent
1a4d1756c1
commit
b5aa1b77b0
@ -69,8 +69,8 @@ class XMPPHP_Log {
|
||||
* @param string $runlevel
|
||||
*/
|
||||
public function __construct($printout = false, $runlevel = self::LEVEL_INFO) {
|
||||
$this->runlevel = (int)$runlevel;
|
||||
$this->printout = (boolean)$printout;
|
||||
$this->runlevel = (int)$runlevel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +169,7 @@ class XMPPHP_XMLStream {
|
||||
* Cleanup connection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if(!$this->disconnected) {
|
||||
if(!$this->disconnected && $this->socket) {
|
||||
$this->disconnect();
|
||||
}
|
||||
}
|
||||
@ -231,10 +231,11 @@ class XMPPHP_XMLStream {
|
||||
/**
|
||||
* Connect to XMPP Host
|
||||
*
|
||||
* @param integer $timeout
|
||||
* @param boolean $persistent
|
||||
* @param boolean $sendinit
|
||||
*/
|
||||
public function connect($persistent = false, $sendinit = true) {
|
||||
public function connect($timeout = 30, $persistent = false, $sendinit = true) {
|
||||
$this->disconnected = false;
|
||||
$this->sent_disconnect = false;
|
||||
if($persistent) {
|
||||
@ -243,7 +244,11 @@ class XMPPHP_XMLStream {
|
||||
$conflag = STREAM_CLIENT_CONNECT;
|
||||
}
|
||||
$this->log->log("Connecting to tcp://{$this->host}:{$this->port}");
|
||||
$this->socket = stream_socket_client("tcp://{$this->host}:{$this->port}", $conflag);
|
||||
try {
|
||||
$this->socket = @stream_socket_client("tcp://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag);
|
||||
} catch (Exception $e) {
|
||||
throw new XMPPHP_Exception($e->getMessage());
|
||||
}
|
||||
if(!$this->socket) {
|
||||
$this->log->log("Could not connect.", XMPPHP_Log::LEVEL_ERROR);
|
||||
$this->disconnected = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user