Added new function calls in server ReadMessage loop
This commit is contained in:
@@ -366,6 +366,44 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
switch (inc.MessageType)
|
||||||
|
{
|
||||||
|
case NetIncomingMessageType.Data:
|
||||||
|
ClientPacketHeader header = (ClientPacketHeader)inc.ReadByte();
|
||||||
|
switch (header)
|
||||||
|
{
|
||||||
|
case ClientPacketHeader.REQUEST_AUTH:
|
||||||
|
ClientAuthRequest(inc.SenderConnection);
|
||||||
|
break;
|
||||||
|
case ClientPacketHeader.REQUEST_INIT:
|
||||||
|
ClientInitialize(inc);
|
||||||
|
break;
|
||||||
|
case ClientPacketHeader.UPDATE_LOBBY:
|
||||||
|
//TODO
|
||||||
|
break;
|
||||||
|
case ClientPacketHeader.UPDATE_INGAME_ALIVE:
|
||||||
|
//TODO
|
||||||
|
break;
|
||||||
|
case ClientPacketHeader.UPDATE_INGAME_SPECTATING:
|
||||||
|
//TODO
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NetIncomingMessageType.ConnectionApproval:
|
||||||
|
if (banList.IsBanned(inc.SenderEndPoint.Address.ToString()))
|
||||||
|
{
|
||||||
|
inc.SenderConnection.Deny("You have been banned from the server");
|
||||||
|
}
|
||||||
|
else if (ConnectedClients.Count >= MaxPlayers)
|
||||||
|
{
|
||||||
|
inc.SenderConnection.Deny("Server full");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc.SenderConnection.Approve();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
List<UnauthenticatedClient> unauthenticatedClients = new List<UnauthenticatedClient>();
|
List<UnauthenticatedClient> unauthenticatedClients = new List<UnauthenticatedClient>();
|
||||||
|
|
||||||
private void ClientPasswordRequest(NetConnection conn)
|
private void ClientAuthRequest(NetConnection conn)
|
||||||
{
|
{
|
||||||
//client wants to know if server requires password
|
//client wants to know if server requires password
|
||||||
|
|
||||||
if (ConnectedClients.Count > MaxPlayers)
|
if (ConnectedClients.Count >= MaxPlayers)
|
||||||
{
|
{
|
||||||
//server is full, can't allow new connection
|
//server is full, can't allow new connection
|
||||||
conn.Disconnect("Server full");
|
conn.Disconnect("Server full");
|
||||||
|
|||||||
Reference in New Issue
Block a user