(PECL stomp >= 0.1.0)
Stomp::__construct -- stomp_connect — 打開一個連接
面向?qū)ο箫L(fēng)格 (constructor):
$broker = ini_get("stomp.default_broker_uri"),$username = ?,$password = ?,$headers = ?過程化風(fēng)格:
$broker = ini_get("stomp.default_broker_uri"),$username = ?,$password = ?,$headers = ?打開一個到兼容stomp通訊協(xié)議的消息代理服務(wù)器的連接.
broker代理服務(wù)器的統(tǒng)一資源標(biāo)識符(URI)。
username用戶名.
password密碼.
headers關(guān)聯(lián)數(shù)組包含附加的頭信息(例如: receipt)。
注意:
A transaction header may be specified, indicating that the message acknowledgment should be part of the named transaction.
| 版本 | 說明 |
|---|---|
| 1.0.1 |
增加了headers 參數(shù)
|
示例 #1 面向?qū)ο箫L(fēng)格
<?php
/* connection */
try {
$stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
die('Connection failed: ' . $e->getMessage());
}
/* close connection */
unset($stomp);
?>
示例 #2 過程化風(fēng)格
<?php
/* connection */
$link = stomp_connect('ssl://localhost:61612');
/* check connection */
if (!$link) {
die('Connection failed: ' . stomp_connect_error());
}
/* close connection */
stomp_close($link);
?>