IPCToolMain* ToolIPCPipeClient::getToolMain() { if (isDisconnected()) return NULL; return m_pServiceMain; }
void Server::checkDisconnections() { for (auto i = clients.begin(); i != clients.end(); ++i) { if (i->isDisconnected()) { clients.erase(i--); std::cout << "Client disconnected." << std::endl; } } }
bool DecayTree::isDecayTreeValid() const { if (hasCycles()) { throw std::runtime_error( "The decay tree has a cyclic dependency, meaning the tree is corrupted. Please fix the configuration file and rerun!"); } if (isDisconnected()) { throw std::runtime_error( "The decay tree is not connected, meaning the tree is corrupted. Please fix the configuration file and rerun!"); } return true; }
void JabberRoomChat::participantChanged(const QString &id) { auto jid = Jid::parse(id); auto contact = m_contactManager->byId(m_chat.chatAccount(), id, ActionCreateAndAdd); auto buddy = m_buddyManager->byContact(contact, ActionCreateAndAdd); buddy.setDisplay(jid.resource()); buddy.setTemporary(true); auto status = m_presenceService->presenceToStatus(m_room->participantPresence(id)); contact.setCurrentStatus(status); auto details = static_cast<ChatDetailsRoom *>(m_chat.details()); if (status.isDisconnected()) details->removeContact(contact); else details->addContact(contact); }
int findDevice(bt_addr_struct *bd_addr) { int i = 0; for(i = 0; i < MAX_DEV_NUM; i++) { if(btmtk_util_equal_bdaddr(&g_dev_oplist[i].bd_addr, bd_addr)) return i; } //ALOGI("%s Find free device\n", __FUNCTION__); for(i = 0; i < MAX_DEV_NUM; i++) { if(isDisconnected(&g_dev_oplist[i].bd_addr)) return i; } //ALOGW("%s all inused\n", __FUNCTION__); return MAX_DEV_NUM; }
void Synchronizer::poll() { int i = 0; T_POLLFD *fds; int nfds; int ret; T_POLLFD tmp; std::deque<ReadWriteHandler *>::iterator it; std::deque<AcceptHandler *>::iterator it2; nfds = this->_acceptHandlers.size() + this->_readHandlers.size() + this->_writeHandlers.size(); fds = new T_POLLFD[nfds]; memset(fds, 0, sizeof(T_POLLFD) * nfds); i = this->construct_reads(fds, i); i = this->construct_writes(fds, i); std::cout << "Starting poll" << std::endl; ret = _poll(fds, nfds, -1); if (ret > 0) { i = 0; for (it = this->_readHandlers.begin(); it != this->_readHandlers.end(); ++i) { tmp = fds[i]; if (hasError(tmp) || isDisconnected(tmp)) { std::cout << "Client #" << (*it)->getId() << " has disconnected" << std::endl; this->_deadClients.push_front((*it)->getId()); it = this->_readHandlers.erase(it); } else if (canRead(tmp)) { (*it)->getBuffer()->setBuffLen((*it)->getSocket()->recv((*it)->getBuffer())); std::cout << "Message '" << (*it)->getBuffer()->getBuffer().buf << "' was read from client #" << (*it)->getId() << std::endl; this->_readClients.push_front(*it); it = this->_readHandlers.erase(it); } else ++it; } for (it2 = this->_acceptHandlers.begin(); it2 != this->_acceptHandlers.end(); ++i) { tmp = fds[i]; if (!hasError(tmp) && canRead(tmp)) { this->_newClients.push_front((*it2)->getSocket()->accept()); std::cout << "New Client has connected" << std::endl; it2 = this->_acceptHandlers.erase(it2); } else ++it2; } for (it = this->_writeHandlers.begin(); it != this->_writeHandlers.end(); ++i) { tmp = fds[i]; if (hasError(tmp) || isDisconnected(tmp)) { std::cout << "Client #" << (*it)->getId() << " has disconnected" << std::endl; this->_deadClients.push_front((*it)->getId()); it = this->_writeHandlers.erase(it); } else if (canWrite(tmp)) { (*it)->getSocket()->send((*it)->getBuffer()); std::cout << "Message '" << (*it)->getBuffer()->getBuffer().buf << "' was sent to client #" << (*it)->getId() << std::endl; it = this->_writeHandlers.erase(it); } else ++it; } } delete fds; }