void App::rebuildPlayerList() { if (!listPlayers || !mClient) return; listPlayers->removeAllItems(); // Add self unsigned peerCount = mClient->getPeerCount(); listPlayers->addItem("#C0E0FF"+pSet->nickname); listPlayers->setSubItemNameAt(1, 0, "#80FFFF"+sListCar); // Car listPlayers->setSubItemNameAt(2, 0, "#C0C0FF"+toStr(peerCount)); // Peers listPlayers->setSubItemNameAt(3, 0, "#C0FFFF""0"); bool rd = mClient->isReady(); // Ping listPlayers->setSubItemNameAt(4, 0, (rd?"#80FF80":"#FF8080")+yesno(rd)); // Ready state // Add others bool allReady = true; const PeerMap peers = mClient->getPeers(); for (PeerMap::const_iterator it = peers.begin(); it != peers.end(); ++it) { if (it->second.name.empty() || it->second.connection == PeerInfo::DISCONNECTED) continue; // Determine if everyone is ready and connected if (it->second.peers != peerCount || !it->second.ready) allReady = false; // Add list item listPlayers->addItem("#C0E0FF"+it->second.name); int l = listPlayers->getItemCount()-1; listPlayers->setSubItemNameAt(1, l, "#80FFFF"+it->second.car); listPlayers->setSubItemNameAt(2, l, "#C0C0FF"+toStr(it->second.peers)); listPlayers->setSubItemNameAt(3, l, "#C0FFFF"+toStr(it->second.ping)); bool rd = it->second.ready; listPlayers->setSubItemNameAt(4, l, (rd?"#80FF80":"#FF8080")+yesno(rd)); } // Allow host to start the game if (mLobbyState == HOSTING) btnNetReady->setEnabled(allReady); }
void ServiceManagement::testMethod() { ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)\n"))); PeerMap map; UUIDPtr pid(UUID::generateUUID()); UUIDPtr pid2(UUID::generateUUID()); UUIDPtr fid(UUID::generateUUID()); UUIDPtr sid(UUID::generateUUID()); UUIDPtr iid1(UUID::generateUUID()); UUIDPtr iid2(UUID::generateUUID()); SAPInfoPtr meshSAP; SAPInfoPtr ftSAP; SAPInfoPtr discoverySAP; PeerInfoPtr peerPtr(new PeerInfoEx(pid,fid,meshSAP,discoverySAP,ftSAP)); map.addPeer(peerPtr); try{ PeerInfoPtr pi; map.getPeerInfo(pid,pi); }catch(PeerException& ex){ ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)ex=%s\n"),ex.toString().c_str())); } try{ PeerInfoPtr pi; map.getPeerInfo(pid2,pi); }catch(PeerException& ex){ ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)ex2=%s\n"),ex.toString().c_str())); } peerPtr->addServiceInstance(sid,iid1); ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)Output:\n%s\n"),peerPtr->toString().c_str())); list<UUIDPtr> l; peerPtr->getInstancesOfService(sid,l); ListHelper<UUIDPtr>::printSmartPtrList(l); ServiceInstanceInfoPtr i; peerPtr->getInstanceOfService(sid,l.front(),i); ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)=====%s\n"),i->toString().c_str())); //bool ret = peerPtr->removeService(sid); //ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%t|%T)after remove = %d\n",ret); //delete l; CPPUNIT_ASSERT(true); }
void cpunbind(void *obj) { BBObject * peer = cpfind(obj); if (peer != &bbNullObject) { peerMap.erase(obj); BBRELEASE(peer); } }
BBObject *cpfind( void *obj ){ if( !obj ) return &bbNullObject; PeerMap::iterator it = peerMap.find( obj ); if( it != peerMap.end() ) return it->second; return &bbNullObject; }
void cpbind( void *obj, BBObject *peer ) { if( !obj || peer==&bbNullObject ) return; peerMap.insert( std::make_pair( obj,peer ) ); BBRETAIN( peer ); }