Stomp::__construct
stomp_connect
Opens a connection
説明
オブジェクト指向型 (constructor):
public Stomp::__construct(
string $broker = ini_get("stomp.default_broker_uri"),
string $username = ?,
string $password = ?,
array $headers = ?
)
手続き型:
resource stomp_connect(
string $broker = ini_get("stomp.default_broker_uri"),
string $username = ?,
string $password = ?,
array $headers = ?
)
Opens a connection to a stomp compliant Message Broker.
パラメータ
-
broker
-
The broker URI
-
username
-
The username.
-
password
-
The password.
-
headers
-
追加のヘッダ (例: receipt) を含む連想配列。
戻り値
注意:
トランザクションヘッダを指定し、そのメッセージがトランザクションの一部であることを示します。
例
例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);
?>