本文整理汇总了C++中message::command方法的典型用法代码示例。如果您正苦于以下问题:C++ message::command方法的具体用法?C++ message::command怎么用?C++ message::command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::command方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: incoming_message
void dns_requester::incoming_message(connection& aConnection, const message& aMessage)
{
if (aMessage.command() != message::NICK)
return;
user oldUser(aMessage.origin(), aConnection);
user newUser(oldUser);
if (!aMessage.parameters().empty())
newUser.nick_name() = aMessage.parameters()[0];
nick_change(oldUser.nick_name(), newUser.nick_name());
}
示例2: whois_result
void dns_requester::whois_result(const message& aMessage)
{
if (aMessage.parameters().empty())
return;
switch(aMessage.command())
{
case message::RPL_WHOISUSER:
case message::ERR_NOSUCHNICK:
for (request_list::iterator i = iRequests.begin(); i != iRequests.end();)
{
if (irc::make_string(iConnection, i->first.nick_name()) == aMessage.parameters()[0])
{
if (aMessage.command() == message::RPL_WHOISUSER)
{
if (aMessage.parameters().size() >= 3)
{
i->first.user_name() = aMessage.parameters()[1];
i->first.host_name() = aMessage.parameters()[2];
iResolver.resolve(*this, i->first.host_name());
}
++i;
}
else
{
i->second->new_message(aMessage);
iRequests.erase(i++);
}
}
else
++i;
}
break;
default:
break;
}
}
示例3: incoming_message
void dcc_send_connection::incoming_message(irc::connection& aConnection, const message& aMessage)
{
if (&aConnection != iConnection)
return;
if (aMessage.command() != message::PRIVMSG)
return;
typedef std::vector<std::pair<std::string::const_iterator, std::string::const_iterator> > bits_t;
bits_t bits;
neolib::tokens(aMessage.content(), std::string("\001 "), bits);
if (neolib::to_upper(neolib::to_string(bits[0])) != "DCC")
return;
if (iSendType == Download && neolib::to_upper(neolib::to_string(bits[1])) == "ACCEPT" && bits.size() >= 5)
{
if (*bits[2].first == '\"')
{
for (bits_t::size_type i = 3; i < bits.size(); ++i)
if (*(bits[i].second - 1) == '\"')
{
bits[2].second = bits[i].second;
bits.erase(bits.begin() + 3, bits.begin() + i + 1);
break;
}
}
std::string fileName = neolib::to_string(bits[2]);
if (fileName == iResumeData->iFileName &&
neolib::string_to_unsigned_integer(neolib::to_string(bits[3])) == iResumeData->iPort &&
neolib::string_to_unsigned_integer(neolib::to_string(bits[4])) == iResumeData->iResumeFileSize)
{
u_long address = iResumeData->iAddress;
u_short port = iResumeData->iPort;
iBytesTransferred = iResumeData->iResumeFileSize;
iLastBytesTransferred = iBytesTransferred;
if (!connect(address, port))
{
close();
return;
}
neolib::observable<dcc_send_connection_observer>::notify_observers(dcc_send_connection_observer::NotifyTransferStarted);
if (!open_file())
return;
}
}
else if (iSendType == Listen && neolib::to_upper(neolib::to_string(bits[1])) == "RESUME" && bits.size() >= 5)
{
if (*bits[2].first == '\"')
{
for (bits_t::size_type i = 3; i < bits.size(); ++i)
if (*(bits[i].second - 1) == '\"')
{
bits[2].second = bits[i].second;
bits.erase(bits.begin() + 3, bits.begin() + i + 1);
break;
}
}
std::string fileName = neolib::to_string(bits[2]);
if (fileName == iName &&
neolib::string_to_unsigned_integer(neolib::to_string(bits[3])) == stream_server().local_port())
{
iResumeData = resume_data_t(0, stream_server().local_port(), name(), neolib::string_to_unsigned_integer(neolib::to_string(bits[4])));
message newMessage(*iConnection, message::OUTGOING);
newMessage.set_command(message::PRIVMSG);
newMessage.parameters().push_back(iRemoteUser.nick_name());
newMessage.parameters().push_back("\001DCC ACCEPT ");
newMessage.parameters().back() += iResumeData->iFileName + " ";
newMessage.parameters().back() += neolib::unsigned_integer_to_string<char>(iResumeData->iPort) + " ";
newMessage.parameters().back() += neolib::unsigned_integer_to_string<char>(iResumeData->iResumeFileSize) + "\001";
iConnection->send_message(newMessage);
}
}
}