本文整理汇总了C++中UserConnection::setState方法的典型用法代码示例。如果您正苦于以下问题:C++ UserConnection::setState方法的具体用法?C++ UserConnection::setState怎么用?C++ UserConnection::setState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserConnection
的用法示例。
在下文中一共展示了UserConnection::setState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例3: connect
void ConnectionManager::connect(const string& aServer, short aPort, const string& aNick) {
if(shuttingDown)
return;
UserConnection* uc = NULL;
try {
uc = getConnection();
uc->setNick(aNick);
uc->setState(UserConnection::STATE_CONNECT);
uc->connect(aServer, aPort);
} catch(const SocketException&) {
if(uc)
putConnection(uc);
}
}
示例4: nmdcConnect
void ConnectionManager::nmdcConnect(const string& aServer, uint16_t aPort, const string& aNick, const string& hubUrl) {
if(shuttingDown)
return;
UserConnection* uc = getConnection(true, false);
uc->setToken(aNick);
uc->setHubUrl(hubUrl);
uc->setState(UserConnection::STATE_CONNECT);
uc->setFlag(UserConnection::FLAG_NMDC);
try {
uc->connect(aServer, aPort);
} catch(const Exception&) {
putConnection(uc);
delete uc;
}
}
示例5: adcConnect
void ConnectionManager::adcConnect(const OnlineUser& aUser, uint16_t aPort, const string& aToken, bool secure) {
if(shuttingDown)
return;
UserConnection* uc = getConnection(false, secure);
uc->setToken(aToken);
uc->setState(UserConnection::STATE_CONNECT);
if(aUser.getIdentity().isOp()) {
uc->setFlag(UserConnection::FLAG_OP);
}
try {
uc->connect(aUser.getIdentity().getIp(), aPort);
} catch(const Exception&) {
putConnection(uc);
delete uc;
}
}