<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Reads the next frame</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="stomp.hasframe.html">Stomp::hasFrame</a></div> <div class="next" style="text-align: right; float: right;"><a href="stomp.send.html">Stomp::send</a></div> <div class="up"><a href="class.stomp.html">Stomp</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="stomp.readframe" class="refentry"> <div class="refnamediv"> <h1 class="refname">Stomp::readFrame</h1> <h1 class="refname">stomp_read_frame</h1> <p class="verinfo">(PECL stomp >= 0.1.0)</p><p class="refpurpose"><span class="refname">Stomp::readFrame</span> -- <span class="refname">stomp_read_frame</span> — <span class="dc-title">Reads the next frame</span></p> </div> <div class="refsect1 description" id="refsect1-stomp.readframe-description"> <h3 class="title">Description</h3> <p class="para">Object oriented style (method):</p> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><a href="class.stompframe.html" class="type stompframe">stompframe</a></span> <span class="methodname"><strong>Stomp::readFrame</strong></span> ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = "stompFrame"</span></span> ] )</div> <p class="para rdfs-comment">Procedural style:</p> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>stomp_read_frame</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link</code></span> )</div> <p class="para rdfs-comment"> Reads the next frame. It is possible to instantiate an object of a specific class, and pass parameters to that class's constructor. </p> </div> <div class="refsect1 parameters" id="refsect1-stomp.readframe-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">link</code></em></span><dd> <p class="para">Procedural style only: The stomp link identifier returned by <span class="function"><a href="stomp.construct.html" class="function">stomp_connect()</a></span>.</p></dd> </dt> <dt> <span class="term"><em><code class="parameter">class_name</code></em></span> <dd> <p class="para"> The name of the class to instantiate. If not specified, a stompFrame object is returned. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-stomp.readframe-returnvalues"> <h3 class="title">Return Values</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">A transaction header may be specified, indicating that the message acknowledgment should be part of the named transaction.</p></p></blockquote> </div> <div class="refsect1 changelog" id="refsect1-stomp.readframe-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>Stomp 0.4.0</td> <td> <em><code class="parameter">class_name</code></em> parameter was added. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-stomp.readframe-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4650"> <p><strong>Example #1 Object oriented style</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">/* connection */<br /></span><span style="color: #007700">try {<br /> </span><span style="color: #0000BB">$stomp </span><span style="color: #007700">= new </span><span style="color: #0000BB">Stomp</span><span style="color: #007700">(</span><span style="color: #DD0000">'tcp://localhost:61613'</span><span style="color: #007700">);<br />} catch(</span><span style="color: #0000BB">StompException $e</span><span style="color: #007700">) {<br /> die(</span><span style="color: #DD0000">'Connection failed: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$e</span><span style="color: #007700">-></span><span style="color: #0000BB">getMessage</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #FF8000">/* subscribe to messages from the queue 'foo' */<br /></span><span style="color: #0000BB">$stomp</span><span style="color: #007700">-></span><span style="color: #0000BB">subscribe</span><span style="color: #007700">(</span><span style="color: #DD0000">'/queue/foo'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* read a frame */<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$stomp</span><span style="color: #007700">-></span><span style="color: #0000BB">readFrame</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">/* close connection */<br /></span><span style="color: #007700">unset(</span><span style="color: #0000BB">$stomp</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> 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" } </pre></div> </div> </div> </p> <p class="para"> <div class="example" id="example-4651"> <p><strong>Example #2 Procedural style</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">/* connection */<br /></span><span style="color: #0000BB">$link </span><span style="color: #007700">= </span><span style="color: #0000BB">stomp_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'ssl://localhost:61612'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* check connection */<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">$link</span><span style="color: #007700">) {<br /> die(</span><span style="color: #DD0000">'Connection failed: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">stomp_connect_error</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #FF8000">/* subscribe to messages from the queue 'foo' */<br /></span><span style="color: #0000BB">stomp_subscribe</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">, </span><span style="color: #DD0000">'/queue/foo'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* read a frame */<br /></span><span style="color: #0000BB">$frame </span><span style="color: #007700">= </span><span style="color: #0000BB">stomp_read_frame</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* close connection */<br /></span><span style="color: #0000BB">stomp_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> 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" } } </pre></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="stomp.hasframe.html">Stomp::hasFrame</a></div> <div class="next" style="text-align: right; float: right;"><a href="stomp.send.html">Stomp::send</a></div> <div class="up"><a href="class.stomp.html">Stomp</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>