void dazeus::Network::onFailedConnection() { fprintf(stderr, "Connection failed on %s\n", dazeus::Network::toString(this).c_str()); identifiedUsers_.clear(); knownUsers_.clear(); slotIrcEvent("DISCONNECT", "", std::vector<std::string>()); // Flag old server as undesirable // Don't destroy it here yet; it is still in the stack. It will be destroyed // in processDescriptors(). flagUndesirableServer( activeServer_->config() ); deleteServer_ = true; }
void dazeus::Server::slotNumericMessageReceived( const std::string &origin, unsigned int code, const std::vector<std::string> &args ) { assert( network_ != 0 ); assert( network_->activeServer() == this ); // Also send out some other interesting events if(code == 311) { in_whois_for_ = args[1]; assert( !whois_identified_ ); } // TODO: should use CAP IDENTIFY_MSG for this: else if(code == 307 || code == 330) // 330 means "logged in as", but doesn't check whether nick is grouped { whois_identified_ = true; } else if(code == 318) { network_->slotWhoisReceived( origin, in_whois_for_, whois_identified_ ); std::vector<std::string> parameters; parameters.push_back(in_whois_for_); parameters.push_back(whois_identified_ ? "true" : "false"); slotIrcEvent( "WHOIS", origin, parameters ); whois_identified_ = false; in_whois_for_.clear(); } // part of NAMES else if(code == 353) { std::vector<std::string> names; std::stringstream ss(args.back()); std::string name; while(std::getline(ss, name, ' ')) { in_names_.push_back(name); } } else if(code == 366) { network_->slotNamesReceived( origin, args.at(1), in_names_, args.at(0) ); std::vector<std::string> parameters; parameters.push_back(args.at(1)); std::vector<std::string>::const_iterator it; for(it = in_names_.begin(); it != in_names_.end(); ++it) { parameters.push_back(*it); } slotIrcEvent( "NAMES", origin, parameters ); in_names_.clear(); } else if(code == 332) { std::vector<std::string> parameters; parameters.push_back(args.at(1)); parameters.push_back(args.at(2)); slotIrcEvent( "TOPIC", origin, parameters ); } std::stringstream codestream; codestream << code; std::vector<std::string> params; params.push_back(codestream.str()); std::vector<std::string>::const_iterator it; for(it = args.begin(); it != args.end(); ++it) { params.push_back(*it); } slotIrcEvent( "NUMERIC", origin, params ); }
/** * Echo an event back to the caller, with a specific echoing name. Used for IRC * commands that generate no replies from the server, such as PRIVMSG and an * ACTION message inside a CTCP message. */ void dazeus::Server::ircEventMe( const std::string &eventname, const std::string &destination, const std::string &message) { std::vector<std::string> parameters; parameters.push_back(destination); parameters.push_back(message); slotIrcEvent(eventname, network_->nick(), parameters); }