コード例 #1
0
void XMPPParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
	if (!parseErrorOccurred_) {
		if (level_ == TopLevel) {
			if (element == "stream" && ns == "http://etherx.jabber.org/streams") {
				ProtocolHeader header;
				header.setFrom(attributes.getAttribute("from"));
				header.setTo(attributes.getAttribute("to"));
				header.setID(attributes.getAttribute("id"));
				header.setVersion(attributes.getAttribute("version"));
				client_->handleStreamStart(header);
			}
			else {
				parseErrorOccurred_ = true;
			}
		}
		else {
			if (level_ == StreamLevel) {
				assert(!currentElementParser_);
				currentElementParser_ = createElementParser(element, ns);
			}
			currentElementParser_->handleStartElement(element, ns, attributes);
		}
	}
	++level_;
}
コード例 #2
0
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);
}