Пример #1
0
 private function _sendAuthenticateFrame(URL $url)
 {
     $frame = $this->sendFrame(new LoginFrame($url->getUser(), $url->getPassword(), $url->getParam('vhost', $url->getHost()), $url->hasParam('versions') ? explode(',', $url->getParam('versions')) : ['1.0', '1.1']));
     if (!$frame instanceof Frame) {
         throw new ProtocolException('Did not receive frame, got: ' . \xp::stringOf($frame));
     }
     if ($frame instanceof ErrorFrame) {
         throw new AuthenticationException('Could not establish connection to broker "' . $url->toString() . '": ' . $frame->getBody(), $url->getUser(), strlen($url->getPassword() > 0) ? 'with password' : 'no password');
     }
     if (!$frame instanceof ConnectedFrame) {
         throw new AuthenticationException('Could not log in to stomp broker "' . $url->toString() . '": Got "' . $frame->command() . '" frame', $url->getUser(), strlen($url->getPassword() > 0) ? 'with password' : 'no password');
     }
     $this->debug('~ Connected to server; server ' . ($frame->getProtocolVersion() ? 'chose protocol version ' . $frame->getProtocolVersion() : 'did not indicate protocol version'));
 }