From 23782ff4e3d01f0cc8816b1888e2ede34a6acf6c Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 24 Jun 2013 12:41:10 +1000 Subject: [PATCH] Removed maximum number of clients --- libs/SDL_net/SDL_net.h | 4 ++-- libs/common/client_entry.hpp | 4 +++- libs/makefile | 1 - server/server_application.cpp | 14 +++----------- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/libs/SDL_net/SDL_net.h b/libs/SDL_net/SDL_net.h index 9258f86..01f1db6 100644 --- a/libs/SDL_net/SDL_net.h +++ b/libs/SDL_net/SDL_net.h @@ -157,9 +157,9 @@ extern DECLSPEC void SDLCALL SDLNet_TCP_Close(TCPsocket sock); /***********************************************************************/ /* The maximum channels on a a UDP socket */ -#define SDLNET_MAX_UDPCHANNELS 150 +#define SDLNET_MAX_UDPCHANNELS 32 /* The maximum addresses bound to a single UDP socket channel */ -#define SDLNET_MAX_UDPADDRESSES 1 +#define SDLNET_MAX_UDPADDRESSES 4 typedef struct _UDPsocket *UDPsocket; typedef struct { diff --git a/libs/common/client_entry.hpp b/libs/common/client_entry.hpp index d2dc41d..3607b5e 100644 --- a/libs/common/client_entry.hpp +++ b/libs/common/client_entry.hpp @@ -22,9 +22,11 @@ #ifndef CLIENTENTRY_HPP_ #define CLIENTENTRY_HPP_ +#include "SDL_net/SDL_net.h" + struct ClientEntry { int index; - int channel; + IPaddress address; int playerIndex; }; diff --git a/libs/makefile b/libs/makefile index cabbc55..8075f4d 100644 --- a/libs/makefile +++ b/libs/makefile @@ -1,7 +1,6 @@ OUTDIR=out all: $(OUTDIR) - $(MAKE) -C SDL_net $(MAKE) -C codebase $(MAKE) -C common diff --git a/server/server_application.cpp b/server/server_application.cpp index f3b0298..0663776 100644 --- a/server/server_application.cpp +++ b/server/server_application.cpp @@ -193,15 +193,8 @@ void ServerApplication::HandleBroadcast(Packet::BroadcastRequest& bcast) { } void ServerApplication::HandleConnection(Packet::JoinRequest& request) { - if (clients.size() >= SDLNET_MAX_UDPCHANNELS) { - //ignore the new connection if there's too many clients connected - return; - } //create the containers - ClientEntry client = { uniqueIndex++ }; - - //bind the address - client.channel = netUtil->Bind(&request.meta.address); + ClientEntry client = {uniqueIndex++, request.meta.address}; //push this information clients[client.index] = client; @@ -211,7 +204,7 @@ void ServerApplication::HandleConnection(Packet::JoinRequest& request) { p.meta.type = Packet::Type::JOIN_RESPONSE; p.joinResponse.clientIndex = client.index; //TODO: resource list - netUtil->Send(client.channel, &p, sizeof(Packet::Packet)); + netUtil->Send(&client.address, &p, sizeof(Packet::Packet)); //pretty cout << "New connection: index " << client.index << endl; @@ -220,8 +213,7 @@ void ServerApplication::HandleConnection(Packet::JoinRequest& request) { void ServerApplication::HandleDisconnection(Packet::Disconnect& disconnect) { //disconnect a client (redundant message) - netUtil->Send(clients[disconnect.clientIndex].channel, &disconnect, sizeof(Packet::Packet)); - netUtil->Unbind(clients[disconnect.clientIndex].channel); + netUtil->Send(&clients[disconnect.clientIndex].address, &disconnect, sizeof(Packet::Packet)); clients.erase(disconnect.clientIndex); //remove the player...