Beispiel #1
0
void SessionListener::messaged(SharedPtr channel, xml_document_ptr& doc) {
    SessionPtr session = SessionPtr::dynamicCast(channel);
    session->clearCounter();
    if(Server::instance().isRenren()) {
        string str = doc->xml();
        changeDomain(str, "renren.com", "xiaonei.com");
        if(!doc->load(str.c_str())) {
            MCE_WARN("SessionListener::messaged --> change domain error");
            return;
        }
    }
    string name = doc->first_child().name();
    if (name == "stream:stream") {
        session->schedule(new StreamAction, doc);
    } else if (name == "starttls") {
        session->execute(new StartTlsAction, doc);
    } else if (name == "auth") {
        session->schedule(new AuthAction, doc);
    } else if (name == "iq") {
        session->schedule(new IqAction, doc);
    } else if (name == "presence") {
        //session->schedule(new PresenceAction, doc);
        //do not start a thread, or a stop may be processed before this presence
        processPresence(session, doc);
    } else {
        session->schedule(new DefultAction, doc);
    }
}
Beispiel #2
0
void SessionListener::messaged(SharedPtr channel, xml_document_ptr& doc) {
	MCE_DEBUG("RequestHandler::handle -> " << doc->xml());
	SessionPtr session = SessionPtr::dynamicCast(channel);
	string name = doc->first_child().attribute("cmd").value();
	if (name == "login") {
		//MCE_DEBUG("SessionListener::messaged --> CONN_ID:"<<session->connectionId());
		//session->schedule(new LoginAction, doc);
		//do not start a thread, otherwise a stop may be processed before this login
		processPresence(session, doc);

	} else if (name == "msg") {
		session->schedule(new ChatAction, doc);
	} else {
		if (doc->child("policy-file-request")) {
			string msg =
			//xiaonei
							"<cross-domain-policy><allow-access-from domain=\"*.xiaonei.com\" to-ports=\"39000\" /></cross-domain-policy>";
			//kaixin
			//"<cross-domain-policy><allow-access-from domain=\"*.kaixin.com\" to-ports=\"39000\" /></cross-domain-policy>";

			msg.push_back('\0');
			session->deliver(msg);
			return;
		}
		session->shutdown();
	}
}