コード例 #1
0
ファイル: Version.php プロジェクト: stomp-php/stomp-php
 /**
  * Version constructor.
  *
  * @param Frame $frame
  * @throws StompException
  */
 public function __construct(Frame $frame)
 {
     if ($frame->getCommand() != 'CONNECTED') {
         throw new UnexpectedResponseException($frame, sprintf('Expected a "CONNECTED" Frame to determine Version. Got a "%s" Frame!', $frame->getCommand()));
     }
     $this->frame = $frame;
 }
コード例 #2
0
ファイル: FrameTest.php プロジェクト: stomp-php/stomp-php
 public function testFrameInLegacyModeWontEncodeHeaders()
 {
     $frame = new Frame('SEND', ['my:var' => "\\multi\nline\r!"]);
     $frame->legacyMode(true);
     $result = $frame->__toString();
     $expected = "SEND\nmy:var:\\multi\\nline\r!\n\n";
     $this->assertEquals($expected, $result);
 }
コード例 #3
0
ファイル: Apollo.php プロジェクト: stomp-php/stomp-php
 /**
  * @inheritdoc
  */
 public function getNackFrame(Frame $frame, $transactionId = null)
 {
     $nack = $this->createFrame('NACK');
     $nack['transaction'] = $transactionId;
     if ($this->hasVersion(Version::VERSION_1_2)) {
         $nack['id'] = $frame['ack'] ?: $frame->getMessageId();
     } else {
         $nack['message-id'] = $frame['ack'] ?: $frame->getMessageId();
         if ($this->hasVersion(Version::VERSION_1_1)) {
             $nack['subscription'] = $frame['subscription'];
         }
     }
     return $nack;
 }
コード例 #4
0
ファイル: OpenMq.php プロジェクト: stomp-php/stomp-php
 /**
  * @inheritdoc
  */
 public function getAckFrame(Frame $frame, $transactionId = null)
 {
     $ack = $this->createFrame('ACK');
     $ack['transaction'] = $transactionId;
     if ($this->hasVersion(Version::VERSION_1_2)) {
         $ack['id'] = $frame->getMessageId();
     } else {
         $ack['message-id'] = $frame->getMessageId();
     }
     // spec quote: "ACK should always specify a "subscription" header for the subscription id that the message to be acked was delivered to ."
     // see https://mq.java.net/4.4-content/stomp-funcspec.html
     $ack['subscription'] = $frame['subscription'];
     return $ack;
 }
コード例 #5
0
 protected function assertIsAbortFrame(Frame $frame)
 {
     $this->assertEquals('ABORT', $frame->getCommand(), 'Frame command is no "abort" command.');
 }
コード例 #6
0
ファイル: ParserTest.php プロジェクト: stomp-php/stomp-php
 public function testParserWontDecodeHeadersInLegacyMode()
 {
     $frame = "COMMAND\nX-Proof:Hello\\c\\r\\n  \\\\World!\n\nBody";
     $this->parser->legacyMode(true);
     $this->parser->addData($frame);
     $this->parser->parse();
     $expected = new Frame('COMMAND', ['X-Proof' => "Hello\\c\\r\n  \\\\World!"], "Body");
     $expected->legacyMode(true);
     $actual = $this->parser->getFrame();
     $this->assertEquals($expected, $actual);
 }
コード例 #7
0
ファイル: Connection.php プロジェクト: stomp-php/stomp-php
 /**
  * Write frame to server.
  *
  * @param Frame $stompFrame
  * @return boolean
  * @throws ConnectionException
  */
 public function writeFrame(Frame $stompFrame)
 {
     if (!$this->isConnected()) {
         throw new ConnectionException('Not connected to any server.', $this->activeHost);
     }
     $data = $stompFrame->__toString();
     if (!@fwrite($this->connection, $data, strlen($data))) {
         throw new ConnectionException('Was not possible to write frame!', $this->activeHost);
     }
     return true;
 }
コード例 #8
0
ファイル: Client.php プロジェクト: stomp-php/stomp-php
 /**
  * Send a message to a destination in the messaging system
  *
  * @param string $destination Destination queue
  * @param string|Frame $msg Message
  * @param array $header
  * @param boolean $sync Perform request synchronously
  * @return boolean
  */
 public function send($destination, $msg, array $header = [], $sync = null)
 {
     if (!$msg instanceof Frame) {
         return $this->send($destination, new Frame('SEND', $header, $msg), [], $sync);
     }
     $msg->addHeaders($header);
     $msg['destination'] = $destination;
     return $this->sendFrame($msg, $sync);
 }