OperationRequestParameters Peer::opCreateRoomImplementation(const JString& gameID, bool isVisible, bool isOpen, nByte maxPlayers, const Hashtable& customRoomProperties, const Hashtable& customLocalPlayerProperties, const JVector<JString>& propsListedInLobby) { OperationRequestParameters op; if(gameID.length()) op.put(ParameterCode::ROOM_NAME, ValueObject<JString>(gameID)); Hashtable roomProps(Utils::stripToCustomProperties(customRoomProperties)); if(!isOpen) roomProps.put(Properties::Room::IS_OPEN, isOpen); if(!isVisible) roomProps.put(Properties::Room::IS_VISIBLE, isVisible); if(maxPlayers) roomProps.put(Properties::Room::MAX_PLAYERS, maxPlayers); JString* propsListedInLobbyArr = allocateArray<JString>(propsListedInLobby.getSize()); for(unsigned int i=0; i<propsListedInLobby.getSize(); ++i) propsListedInLobbyArr[i] = propsListedInLobby[i]; roomProps.put(Properties::Room::PROPS_LISTED_IN_LOBBY, propsListedInLobbyArr, propsListedInLobby.getSize()); deallocateArray(propsListedInLobbyArr); op.put(ParameterCode::ROOM_PROPERTIES, ValueObject<Hashtable>(roomProps)); Hashtable playerProperties = Utils::stripToCustomProperties(customLocalPlayerProperties); if(playerProperties.getSize()) op.put(ParameterCode::PLAYER_PROPERTIES, ValueObject<Hashtable>(playerProperties)); op.put(ParameterCode::BROADCAST, ValueObject<bool>(true)); op.put(ParameterCode::CLEANUP_CACHE_ON_LEAVE, ValueObject<bool>(true)); return op; }
void MutableRoom::setPropsListedInLobby(const JVector<JString>& propsListedInLobby) { if(mPropsListedInLobby != propsListedInLobby) { mPropsListedInLobby = propsListedInLobby; JString* propsListedInLobbyArr = allocateArray<JString>(propsListedInLobby.getSize()); for(unsigned int i=0; i<propsListedInLobby.getSize(); ++i) propsListedInLobbyArr[i] = propsListedInLobby[i]; Hashtable properties; properties.put(static_cast<nByte>(Properties::Room::PROPS_LISTED_IN_LOBBY), propsListedInLobbyArr, propsListedInLobby.getSize()); deallocateArray(propsListedInLobbyArr); mLoadBalancingPeer->opSetPropertiesOfRoom(properties); } }
void LoadBalancingListener::onLobbyStatsUpdate(const JVector<LobbyStatsResponse>& res) { mpView->info("===================== lobby stats update"); for(unsigned int i=0; i<res.getSize(); ++i) mpView->info(res[i].toString().UTF8Representation().cstr()); // lobby stats request test JVector<LobbyStatsRequest> ls; ls.addElement(LobbyStatsRequest()); ls.addElement(LobbyStatsRequest(L"AAA")); ls.addElement(LobbyStatsRequest(L"BBB")); ls.addElement(LobbyStatsRequest(L"CCC", LobbyType::DEFAULT)); ls.addElement(LobbyStatsRequest(L"AAA", LobbyType::SQL_LOBBY)); mpLbc->opLobbyStats(ls); // mpLbc->opLobbyStats(); }