void ClientManager::sendUDP(AdcCommand& cmd, const OnlineUser& user) { dcassert(cmd.getType() == AdcCommand::TYPE_UDP); if(!user.getIdentity().isUdpActive()) { cmd.setType(AdcCommand::TYPE_DIRECT); cmd.setTo(user.getIdentity().getSID()); const_cast<Client&>(user.getClient()).send(cmd); } else { sendUDP(user.getIdentity().getIp(), user.getIdentity().getUdpPort(), cmd.toString(getMe()->getCID())); } }
void ClientManager::send(AdcCommand& cmd, const CID& cid) { Lock l(cs); OnlineIter i = onlineUsers.find(cid); if(i != onlineUsers.end()) { OnlineUser& u = *i->second; if(cmd.getType() == AdcCommand::TYPE_UDP && !u.getIdentity().isUdpActive()) { cmd.setType(AdcCommand::TYPE_DIRECT); cmd.setTo(u.getIdentity().getSID()); u.getClient().send(cmd); } else { try { udp.writeTo(u.getIdentity().getIp(), static_cast<uint16_t>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID())); } catch(const SocketException&) { dcdebug("Socket exception sending ADC UDP command\n"); } } } }