本文整理汇总了C++中IArchive::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ IArchive::Length方法的具体用法?C++ IArchive::Length怎么用?C++ IArchive::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IArchive
的用法示例。
在下文中一共展示了IArchive::Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Send
bool NetSystem::Send(const UI32 nSocket, const IArchive & msg) {
if (nSocket >= 65335) { //如何控制这个端口的范围
LOG_ERROR("NetSystem::Send nSocket : %d", nSocket);
Assert(false);
return false;
}
LinkInfo * pLinkInfo = m_linkmanage.FindLinkBySocket(nSocket);
if (NULL == pLinkInfo) {
LOG_ERROR("NetSystem::Send LinkInfo is NULL");
Assert(false);
return false;
}
pLinkInfo->m_sendstream.WriteBuff(msg.GetStream(), msg.Length());
struct epoll_event ev;
ev.data.ptr = pLinkInfo;
ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
epoll_ctl(m_epfd, EPOLL_CTL_MOD, pLinkInfo->m_socket, &ev);
return true;
}
示例2: BroadCast
bool NetSystem::BroadCast(const char * pLinkType, const IArchive & msg,
const IVarList & blacklist) {
if (NULL == pLinkType || !m_linkmanage.IsExsitType(pLinkType) || 0 == msg.Length()) {
LOG_ERROR("LinkType : %s, MsgLength : %d", pLinkType, msg.Length());
Assert(false);
return false;
}
const vector<LinkInfo *> * pVct = m_linkmanage.GetTypeOfLinks(pLinkType);
vector<LinkInfo *>::const_iterator itor = pVct->begin();
const vector<LinkInfo *>::const_iterator iend = pVct->end();
UI32 nCount = blacklist.Count();
while (itor != iend) {
for (UI32 i = 0; i < nCount; i++) {
if (blacklist.Type(i) != TYPE_INT) {
LOG_ERROR("Error BlackList element type");
Assert(false);
continue;
}
if ((*itor)->m_socket == blacklist.GetInt(i)) {
continue;
}
}
(*itor)->m_sendstream.WriteBuff(msg.GetStream(), msg.Length());
struct epoll_event ev;
ev.data.ptr = *itor;
ev.events = EPOLLOUT | EPOLLET;
epoll_ctl(m_epfd, EPOLL_CTL_MOD, (*itor)->m_socket, &ev);
itor++;
}
return true;
}