本文整理汇总了C++中Stanza::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Stanza::getAttribute方法的具体用法?C++ Stanza::getAttribute怎么用?C++ Stanza::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stanza
的用法示例。
在下文中一共展示了Stanza::getAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleStanza
int GroupchatTask::handleStanza(Stanza& stanza, StanzaHandlerResult& result)
{
// Buddy presence
// <presence/>
int ok = 1;
int bUsed = 0;
String sType = stanza.getAttribute("type").getValue();
if (stanza.getName() == "message" && sType == "groupchat") {
JabberId from = stanza.getAttribute("from").getValue();
apLog_Verbose((LOG_CHANNEL, LOG_CONTEXT, "<message from=%s ...", _sz(from)));
Room* pRoom = pClient_->findRoom(from.base());
if (pRoom) {
ok = pRoom->receiveGroupchat(stanza);
bUsed = 1;
}
}
if (bUsed) {
result.stanzaHandled(1);
result.stanzaConsumed(1);
}
return ok;
}
示例2: sendResponse
int VersionTask::sendResponse(Stanza& stanza)
{
// <iq type='result' id='jcl_9' to='[email protected]/exodus' from='[email protected]/Winjab'>
// <query xmlns='jabber:iq:version'>
// <name>Winjab</name>
// <version>1.1.0.1</version>
// <os>NT 5.0</os>
// </query>
// </iq>
int ok = 1;
String sId = stanza.getAttribute("id").getValue();
String sFrom = stanza.getAttribute("from").getValue();
if (sFrom.empty()) {
ok = 0;
apLog_Warning((LOG_CHANNEL, LOG_CONTEXT, "missing from"));
} else {
ResultStanza result(sId, sFrom);
Apollo::XMLNode& AP_UNUSED_VARIABLE query = result.addQuery(XMPP_NS_VERSION);
String sName = Apollo::getModuleConfig(MODULE_NAME, "ClientInfo/Name", "Apollo");
String sVersion = Apollo::getModuleConfig(MODULE_NAME, "ClientInfo/Version", "0.1");
String sOs = Apollo::getModuleConfig(MODULE_NAME, "ClientInfo/OS", "Unknown");
Apollo::XMLNode& name = result.addChildRef("name");
if (name) {
name.setCData(sName);
}
Apollo::XMLNode& version = result.addChildRef("version");
if (version) {
version.setCData(sVersion);
}
Apollo::XMLNode& os = result.addChildRef("os");
if (os) {
os.setCData(sOs);
}
ok = pClient_->sendStanza(result);
if (!ok) {
apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "pClient_->sendStanza() failed to=%s", _sz(sFrom)));
}
}
return ok;
}
示例3: reply
/**
* Создать заготовку-ответ на комманду
*/
AdHocCommand AdHocCommand::reply(Stanza stanza)
{
Stanza reply = new XmlTag("iq");
reply->setAttribute("from", stanza.to().full());
reply->setAttribute("to", stanza.from().full());
reply->setAttribute("id", stanza->getAttribute("id"));
reply->setAttribute("type", "result");
Stanza command = reply["command"];
command->setDefaultNameSpaceAttribute("http://jabber.org/protocol/commands");
command->setAttribute("node", stanza["command"]->getAttribute("node"));
command["x"]->setDefaultNameSpaceAttribute("jabber:x:data");
return reply;
}