4 * Copyright 2005-2006 The Apache Software Foundation
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
19 /* vim: set expandtab tabstop=3 shiftwidth=3: */
\r
22 * Stomp Frames are messages that are sent and received on a stomp connection.
\r
29 public $headers = array();
\r
35 * @param string $command
\r
36 * @param array $headers
\r
37 * @param string $body
\r
39 public function __construct ($command = null, $headers = null, $body = null)
\r
41 $this->_init($command, $headers, $body);
\r
44 protected function _init ($command = null, $headers = null, $body = null)
\r
46 $this->command = $command;
\r
47 if ($headers != null) {
\r
48 $this->headers = $headers;
\r
50 $this->body = $body;
\r
52 if ($this->command == 'ERROR') {
\r
53 require_once 'Exception.php';
\r
54 throw new StompException($this->headers['message'], 0, $this->body);
\r
59 * Convert frame to transportable string
\r
63 public function __toString()
\r
65 $data = $this->command . "\n";
\r
67 foreach ($this->headers as $name => $value) {
\r
68 $data .= $name . ": " . $value . "\n";
\r
72 $data .= $this->body;
\r
73 return $data .= "\x00";
\r