4 * Copyright 2005-2006 The Apache Software Foundation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 /* vim: set expandtab tabstop=3 shiftwidth=3: */
22 * Stomp Frames are messages that are sent and received on a StompConnection.
\r
25 * @author Hiram Chirino <hiram@hiramchirino.com>
\r
26 * @author Dejan Bosanac <dejan@nighttale.net>
\r
27 * @author Michael Caplan <mcaplan@labnet.net>
\r
28 * @version $Revision: 36 $
\r
33 public $headers = array();
\r
39 * @param string $command
\r
40 * @param array $headers
\r
41 * @param string $body
\r
43 public function __construct ($command = null, $headers = null, $body = null)
\r
45 $this->_init($command, $headers, $body);
\r
48 protected function _init ($command = null, $headers = null, $body = null)
\r
50 $this->command = $command;
\r
51 if ($headers != null) {
\r
52 $this->headers = $headers;
\r
54 $this->body = $body;
\r
56 if ($this->command == 'ERROR') {
\r
57 require_once 'Stomp/Exception.php';
\r
58 throw new Stomp_Exception($this->headers['message'], 0, $this->body);
\r
63 * Convert frame to transportable string
67 public function __toString()
69 $data = $this->command . "\n";
71 foreach ($this->headers as $name => $value) {
72 $data .= $name . ": " . $value . "\n";
77 return $data .= "\x00\n";