Stomp::__construct

stomp_connect

(PECL stomp >= 0.1.0)

Stomp::__construct -- stomp_connect打開(kāi)一個(gè)連接

說(shuō)明

面向?qū)ο箫L(fēng)格 (constructor):

public Stomp::__construct(
    string $broker = ini_get("stomp.default_broker_uri"),
    string $username = ?,
    string $password = ?,
    array $headers = ?
)

過(guò)程化風(fēng)格:

stomp_connect(
    string $broker = ini_get("stomp.default_broker_uri"),
    string $username = ?,
    string $password = ?,
    array $headers = ?
): resource

打開(kāi)一個(gè)到兼容stomp通訊協(xié)議的消息代理服務(wù)器的連接.

參數(shù)

broker

代理服務(wù)器的統(tǒng)一資源標(biāo)識(shí)符(URI)。

username

用戶(hù)名.

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.

更新日志

版本 說(shuō)明
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 過(guò)程化風(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);

?>