std::string XMPPSerializer::serializeHeader(const ProtocolHeader& header) const { std::string result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"" + getDefaultNamespace() + "\" xmlns:stream=\"http://etherx.jabber.org/streams\""; if (!header.getFrom().empty()) { result += " from=\"" + header.getFrom() + "\""; } if (!header.getTo().empty()) { result += " to=\"" + header.getTo() + "\""; } if (!header.getID().empty()) { result += " id=\"" + header.getID() + "\""; } if (!header.getVersion().empty()) { result += " version=\"" + header.getVersion() + "\""; } result += ">"; return result; }
void ServerFromClientSession::handleStreamStart(const ProtocolHeader& incomingHeader) { setLocalJID(JID("", incomingHeader.getTo())); ProtocolHeader header; header.setFrom(incomingHeader.getTo()); header.setID(id_); getXMPPLayer()->writeHeader(header); boost::shared_ptr<StreamFeatures> features(new StreamFeatures()); if (!authenticated_) { features->addAuthenticationMechanism("PLAIN"); if (allowSASLEXTERNAL) { features->addAuthenticationMechanism("EXTERNAL"); } } else { features->setHasResourceBind(); features->setHasSession(); } getXMPPLayer()->writeElement(features); }