本文整理汇总了C++中UserConnection::setLastActivity方法的典型用法代码示例。如果您正苦于以下问题:C++ UserConnection::setLastActivity方法的具体用法?C++ UserConnection::setLastActivity怎么用?C++ UserConnection::setLastActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserConnection
的用法示例。
在下文中一共展示了UserConnection::setLastActivity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
/**
* Someone's connecting, accept the connection and wait for identification...
* It's always the other fellow that starts sending if he made the connection.
*/
void ConnectionManager::accept(const Socket& sock, bool secure) throw() {
uint32_t now = GET_TICK();
if(now > floodCounter) {
floodCounter = now + FLOOD_ADD;
} else {
if(false && now + FLOOD_TRIGGER < floodCounter) {
Socket s;
try {
s.accept(sock);
} catch(const SocketException&) {
// ...
}
dcdebug("Connection flood detected!\n");
return;
} else {
floodCounter += FLOOD_ADD;
}
}
UserConnection* uc = getConnection(false, secure);
uc->setFlag(UserConnection::FLAG_INCOMING);
uc->setState(UserConnection::STATE_SUPNICK);
uc->setLastActivity(GET_TICK());
try {
uc->accept(sock);
} catch(const Exception&) {
putConnection(uc);
delete uc;
}
}
示例2: on
/**
* Someone's connecting, accept the connection and wait for identification...
* It's always the other fellow that starts sending if he made the connection.
*/
void ConnectionManager::on(ServerSocketListener::IncomingConnection) throw() {
UserConnection* uc = NULL;
u_int32_t now = GET_TICK();
if(now > floodCounter) {
floodCounter = now + FLOOD_ADD;
} else {
if(now + FLOOD_TRIGGER < floodCounter) {
Socket s;
try {
s.accept(socket);
} catch(const SocketException&) {
// ...
}
dcdebug("Connection flood detected!\n");
return;
} else {
floodCounter += 2000;
}
}
try {
uc = getConnection();
uc->setFlag(UserConnection::FLAG_INCOMING);
uc->setState(UserConnection::STATE_NICK);
uc->setLastActivity(GET_TICK());
uc->accept(socket);
} catch(const SocketException& e) {
dcdebug("ConnectionManager::OnIncomingConnection caught: %s\n", e.getError().c_str());
if(uc)
putConnection(uc);
}
}