Removed maximum number of clients

This commit is contained in:
Kayne Ruse
2013-06-24 12:41:10 +10:00
parent 2a46f82f84
commit 23782ff4e3
4 changed files with 8 additions and 15 deletions
+2 -2
View File
@@ -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 {
+3 -1
View File
@@ -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;
};
-1
View File
@@ -1,7 +1,6 @@
OUTDIR=out
all: $(OUTDIR)
$(MAKE) -C SDL_net
$(MAKE) -C codebase
$(MAKE) -C common
+3 -11
View File
@@ -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...