Removed maximum number of clients
This commit is contained in:
@@ -157,9 +157,9 @@ extern DECLSPEC void SDLCALL SDLNet_TCP_Close(TCPsocket sock);
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
/* The maximum channels on a a UDP socket */
|
/* 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 */
|
/* 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 _UDPsocket *UDPsocket;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -22,9 +22,11 @@
|
|||||||
#ifndef CLIENTENTRY_HPP_
|
#ifndef CLIENTENTRY_HPP_
|
||||||
#define CLIENTENTRY_HPP_
|
#define CLIENTENTRY_HPP_
|
||||||
|
|
||||||
|
#include "SDL_net/SDL_net.h"
|
||||||
|
|
||||||
struct ClientEntry {
|
struct ClientEntry {
|
||||||
int index;
|
int index;
|
||||||
int channel;
|
IPaddress address;
|
||||||
int playerIndex;
|
int playerIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
OUTDIR=out
|
OUTDIR=out
|
||||||
|
|
||||||
all: $(OUTDIR)
|
all: $(OUTDIR)
|
||||||
$(MAKE) -C SDL_net
|
|
||||||
$(MAKE) -C codebase
|
$(MAKE) -C codebase
|
||||||
$(MAKE) -C common
|
$(MAKE) -C common
|
||||||
|
|
||||||
|
|||||||
@@ -193,15 +193,8 @@ void ServerApplication::HandleBroadcast(Packet::BroadcastRequest& bcast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleConnection(Packet::JoinRequest& request) {
|
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
|
//create the containers
|
||||||
ClientEntry client = { uniqueIndex++ };
|
ClientEntry client = {uniqueIndex++, request.meta.address};
|
||||||
|
|
||||||
//bind the address
|
|
||||||
client.channel = netUtil->Bind(&request.meta.address);
|
|
||||||
|
|
||||||
//push this information
|
//push this information
|
||||||
clients[client.index] = client;
|
clients[client.index] = client;
|
||||||
@@ -211,7 +204,7 @@ void ServerApplication::HandleConnection(Packet::JoinRequest& request) {
|
|||||||
p.meta.type = Packet::Type::JOIN_RESPONSE;
|
p.meta.type = Packet::Type::JOIN_RESPONSE;
|
||||||
p.joinResponse.clientIndex = client.index;
|
p.joinResponse.clientIndex = client.index;
|
||||||
//TODO: resource list
|
//TODO: resource list
|
||||||
netUtil->Send(client.channel, &p, sizeof(Packet::Packet));
|
netUtil->Send(&client.address, &p, sizeof(Packet::Packet));
|
||||||
|
|
||||||
//pretty
|
//pretty
|
||||||
cout << "New connection: index " << client.index << endl;
|
cout << "New connection: index " << client.index << endl;
|
||||||
@@ -220,8 +213,7 @@ void ServerApplication::HandleConnection(Packet::JoinRequest& request) {
|
|||||||
|
|
||||||
void ServerApplication::HandleDisconnection(Packet::Disconnect& disconnect) {
|
void ServerApplication::HandleDisconnection(Packet::Disconnect& disconnect) {
|
||||||
//disconnect a client (redundant message)
|
//disconnect a client (redundant message)
|
||||||
netUtil->Send(clients[disconnect.clientIndex].channel, &disconnect, sizeof(Packet::Packet));
|
netUtil->Send(&clients[disconnect.clientIndex].address, &disconnect, sizeof(Packet::Packet));
|
||||||
netUtil->Unbind(clients[disconnect.clientIndex].channel);
|
|
||||||
clients.erase(disconnect.clientIndex);
|
clients.erase(disconnect.clientIndex);
|
||||||
|
|
||||||
//remove the player...
|
//remove the player...
|
||||||
|
|||||||
Reference in New Issue
Block a user