Stomp::__construct
stomp_connect
(PECL stomp >= 0.1.0)
Stomp::__construct -- stomp_connect — 打开连接
说明
面向对象风格 (constructor):
public Stomp::__construct(
string
string
string
array
)
string
$broker
= ini_get("stomp.default_broker_uri"),string
$username
= ?,string
$password
= ?,array
$headers
= ?)
过程化风格:
stomp_connect(
string
string
string
array
): resource
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.
更新日志
版本 | 说明 |
---|---|
PECL stomp 1.0.1 |
增加 headers 参数
|
示例
示例 #1 面向对象风格
<?php
/* 连接 */
try {
$stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
die('Connection failed: ' . $e->getMessage());
}
/* close connection */
unset($stomp);
?>
示例 #2 过程化风格
<?php
/* 连接 */
$link = stomp_connect('ssl://localhost:61612');
/* 检查链接 */
if (!$link) {
die('Connection failed: ' . stomp_connect_error());
}
/* 关闭连接 */
stomp_close($link);
?>
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。