Stomp::__construct

stomp_connect

(PECL stomp >= 0.1.0)

Stomp::__construct -- stomp_connect打开连接

说明

面向对象风格 (constructor):

publicStomp::__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.

更新日志

版本说明
PECL stomp 1.0.1 增加 headers 参数

示例

示例 #1 面向对象风格

<?php


try {
$stomp = new Stomp('tcp://localhost:61613');
} catch(
StompException $e) {
die(
'Connection failed: ' . $e->getMessage());
}


unset($stomp);

?>

示例 #2 过程化风格

<?php


$link = stomp_connect('ssl://localhost:61612');


if (!$link) {
die(
'Connection failed: ' . stomp_connect_error());
}


stomp_close($link);

?>
To Top