Stomp::__construct
stomp_connect
(PECL stomp >= 0.1.0)
Stomp::__construct -- stomp_connect — 打开一个连接
说明
面向对象风格 (constructor):
public Stomp::__construct
( string
$broker
= ini_get("stomp.default_broker_uri")
, string $username
= ?
, string $password
= ?
, array $headers
= ?
)过程化风格:
stomp_connect
( string
$broker
= ini_get("stomp.default_broker_uri")
, string $username
= ?
, string $password
= ?
, array $headers
= ?
) : resource打开一个到兼容stomp通讯协议的消息代理服务器的连接.
参数
-
broker
-
代理服务器的统一资源标识符(URI)。
-
username
-
用户名.
-
password
-
密码.
-
headers
-
关联数组包含附加的头信息(例如: receipt)。
返回值
注意:
A transaction header may be specified, indicating that the message acknowledgment should be part of the named transaction.
更新日志
版本 | 说明 |
---|---|
1.0.1 |
增加了headers 参数
|
范例
示例 #1 面向对象风格
<?php
/* connection */
try {
$stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
die('Connection failed: ' . $e->getMessage());
}
/* close connection */
unset($stomp);
?>
示例 #2 过程化风格
<?php
/* connection */
$link = stomp_connect('ssl://localhost:61612');
/* check connection */
if (!$link) {
die('Connection failed: ' . stomp_connect_error());
}
/* close connection */
stomp_close($link);
?>