Example #1
0
bool NetworkEngine::canConnected(RakNet::SystemAddress id)
{
	RakNet::SystemAddress connecteds[MAX_PLAYERS];
	unsigned short size = MAX_PLAYERS;
	//unsigned short pos = peer->NumberOfConnections();
	//peer->GetConnectionList(connecteds,&pos);
	peer->GetConnectionList((RakNet::SystemAddress*) &connecteds,&size);

	if(disconnecteds.size() > 0)
	{
		std::vector<RakNet::SystemAddress>::iterator it = disconnecteds.begin();
		do
		{
			if(id.EqualsExcludingPort(*it))
			{
				disconnecteds.erase(it);
				return true;
			}
			it++;
		}while(it != disconnecteds.end());
	}

	for(int i=0;i<MAX_PLAYERS;i++)
	{
		if(connecteds[i].EqualsExcludingPort(id))
		{
			return false;
		}
	}

	return false;
}
Example #2
0
bool Network::is_in_same_network(std::string const& other) const {
  RakNet::SystemAddress o;
  RakNet::SystemAddress self;
  if (o.FromString(other.c_str()) && self.FromString(external_id_.c_str())) {
    if (o.EqualsExcludingPort(self)) {
      return true;
    }
  }
  return false;
}