Ejemplo n.º 1
0
bool BellServer::registerClient(uint32 key, socketuid_t uid, BellSocket *socket)
{
	ClientsIt clientIt;
	ClientsBellsIt bellIt;
	
	// Skip uid == 0 as that is reserved
	if(uid == 0)
		return false;
	
	// Check if this key even exists
	bellIt = clientBells_.find(key);
	if(bellIt == clientBells_.end())
	{
		printf("This key does not exists!\n");
		return false;
	}
	
	// Check if it already exists if so we can not register you
	Clients *bells = &clientBells_[key];
	clientIt = bells->find(uid);
	if(clientIt != bells->end())
		return false;
	
	// Register this socket
	(*bells)[uid] = socket;
	return true;
}
Ejemplo n.º 2
0
void Game::process()
{
   Admin* admin;
   Client * player;
   Clients* clients = mClientMgr.list();
   bool worldSave = false;
   for (Clients::iterator client=clients->begin(); client != clients->end(); client++)
   {
      player = client->second;
      if (player->isAdmin())
      {
         admin = player->getAdmin();

         /* Add any buildings that an admin has placed down. */
         processBuildingReqs(admin);

         /* Check if the save command was issued */
         if (admin->getWorldSaveReq())
         {
            worldSave = true;
         }
      }
   }

   if (worldSave)
   {
      mZoneMgr.saveWorld();
   }
}
Ejemplo n.º 3
0
std::string get_name_by_sock(Clients clients, int sockfd)
{
   /* cauta numele dupa socket */
   std::map <std::string, ClientInfo> ::iterator it;
   
   for (it = clients.begin(); it != clients.end(); it++)
      if ((*it).second.getSock() == sockfd)
	 return (*it).first;
      
   return "anonymous";
}
Ejemplo n.º 4
0
void BellServer::handleButton(uint8 buttonNo)
{
	switch(buttonNo)
	{
		case 6:
			printf("Call all\n");
		break;
		default:
			uint32 key = indexToKey(buttonNo);
			printf("Calling client %i with key: %08X\n", buttonNo, key);
			Clients *bells = &clientBells_[key];
			
			// Go through all client attached to this bell
			for(ClientsIt it=bells->begin(); it!=bells->end(); it++)
			{
				if(it->first == 0) continue;
				BellSocket *socket = it->second;
				socket->handleCall();
			}
		break;
	}
}