1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 18:36:37 +02:00

Remove send_cmd and replace it with a stringstream

This commit is contained in:
Adam
2011-11-25 00:44:31 -05:00
parent 12d0a7302f
commit cef3eb78df
17 changed files with 417 additions and 581 deletions
+53 -1
View File
@@ -125,7 +125,7 @@ UplinkSocket::~UplinkSocket()
}
}
ircdproto->SendSquit(Config->ServerName, quitmsg);
ircdproto->SendSquit(Me, quitmsg);
this->ProcessWrite(); // Write out the last bit
}
@@ -172,6 +172,58 @@ void UplinkSocket::OnError(const Anope::string &error)
Log(LOG_TERMINAL) << "Unable to connect to server " << Config->Uplinks[CurrentUplink]->host << ":" << Config->Uplinks[CurrentUplink]->port << (!error.empty() ? (": " + error) : "");
}
UplinkSocket::Message::Message()
{
}
UplinkSocket::Message::Message(const Anope::string &s) : source(s)
{
}
UplinkSocket::Message::~Message()
{
if (!UplinkSock)
{
if (!this->source.empty())
Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with UplinkSock NULL";
else
Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" with UplinkSock NULL";
return;
}
if (this->source == Me->GetName())
{
if (ircd->ts6)
this->source = Me->GetSID();
}
else if (!this->source.empty() && this->source != Me->GetSID())
{
BotInfo *bi = findbot(this->source);
if (bi != NULL)
{
if (bi->introduced == false)
{
Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with source not introduced";
return;
}
if (ircd->ts6)
this->source = bi->GetUID();
}
}
if (!this->source.empty())
{
UplinkSock->Write(":" + this->source + " " + this->buffer.str());
Log(LOG_RAWIO) << "Sent: :" << this->source << " " << this->buffer.str();
}
else
{
UplinkSock->Write(this->buffer.str());
Log(LOG_RAWIO) << "Sent: " << this->buffer.str();
}
}
static void Connect()
{
if (static_cast<unsigned>(++CurrentUplink) >= Config->Uplinks.size())