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.
25 * @author Hiram Chirino <hiram@hiramchirino.com>
26 * @author Dejan Bosanac <dejan@nighttale.net>
27 * @author Michael Caplan <mcaplan@labnet.net>
28 * @version $Revision: 36 $
33 public $headers = array();
39 * @param string $command
40 * @param array $headers
43 public function __construct ($command = null, $headers = null, $body = null)
45 $this->_init($command, $headers, $body);
48 protected function _init ($command = null, $headers = null, $body = null)
50 $this->command = $command;
51 if ($headers != null) {
52 $this->headers = $headers;
56 if ($this->command == 'ERROR') {
57 require_once 'Stomp/Exception.php';
58 throw new Stomp_Exception($this->headers['message'], 0, $this->body);
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 $data .= "\x00\n"; // Should there really be a linefeed here?