Stomp Client Stomp::readFrame

stomp_read_frame

(PECL stomp >= 0.1.0)

Stomp::readFrame -- stomp_read_frame — 다음 프레임을 읽습니다.


설명

객체 지향 스타일(메소드):

public Stomp::readFrame(string class_name = "stompFrame"): stompframe

절차 스타일:

stomp_read_frame(resource $link): array

다음 프레임을 읽습니다. 특정 클래스의 개체를 인스턴스화하고 해당 클래스의 생성자에 매개변수를 전달할 수 있습니다.


매개변수

link
절차 스타일만 해당: stomp_connect()에 의해 반환된 stomp 링크 식별자입니다.
class_name
인스턴스화할 클래스의 이름입니다. 지정하지 않으면 stompFrame 객체가 반환됩니다.

반환 값

메모: 메시지 승인이 명명된 트랜잭션의 일부여야 함을 나타내는 트랜잭션 헤더가 지정될 수 있습니다.


변경 로그

버전 설명
Stomp 0.4.0 class_name 매개변수가 추가되었습니다.

Examples

예제 #1 객체 지향 스타일

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

/* subscribe to messages from the queue 'foo' */
$stomp->subscribe('/queue/foo');

/* read a frame */
var_dump($stomp->readFrame());

/* close connection */
unset($stomp);
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

object(StompFrame)#2 (3) {
  ["command"]=>
  string(7) "MESSAGE"
  ["headers"]=>
  array(5) {
    ["message-id"]=>
    string(41) "ID:php.net-55293-1257226743606-4:2:-1:1:1"
    ["destination"]=>
    string(10) "/queue/foo"
    ["timestamp"]=>
    string(13) "1257226805828"
    ["expires"]=>
    string(1) "0"
    ["priority"]=>
    string(1) "0"
  }
  ["body"]=>
  string(3) "bar"
}
                

예제 #2 절차적 스타일

                  
<?php
/* connection */
$link = stomp_connect('ssl://localhost:61612');

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

/* subscribe to messages from the queue 'foo' */
stomp_subscribe($link, '/queue/foo');

/* read a frame */
$frame = stomp_read_frame($link);

/* close connection */
stomp_close($link);
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

array(3) {
  ["command"]=>
  string(7) "MESSAGE"
  ["body"]=>
  string(3) "bar"
  ["headers"]=>
  array(6) {
    ["transaction"]=>
    string(2) "t1"
    ["message-id"]=>
    string(41) "ID:php.net-55293-1257226743606-4:3:-1:1:1"
    ["destination"]=>
    string(10) "/queue/foo"
    ["timestamp"]=>
    string(13) "1257227037059"
    ["expires"]=>
    string(1) "0"
    ["priority"]=>
    string(1) "0"
  }
}