summaryrefslogtreecommitdiff
path: root/src/net_common.c
diff options
context:
space:
mode:
authorSimon Howard2006-01-08 04:52:26 +0000
committerSimon Howard2006-01-08 04:52:26 +0000
commit8df3eb7ce027ec1a73c8fce879ee0d59ac4e49c9 (patch)
tree3067618f038a0b45ca0dcdadcddf14f44f7b55f8 /src/net_common.c
parent0a55e76dc58993267abb4b0cde944f1babecc242 (diff)
downloadchocolate-doom-8df3eb7ce027ec1a73c8fce879ee0d59ac4e49c9.tar.gz
chocolate-doom-8df3eb7ce027ec1a73c8fce879ee0d59ac4e49c9.tar.bz2
chocolate-doom-8df3eb7ce027ec1a73c8fce879ee0d59ac4e49c9.zip
Allow the server to reject clients
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 268
Diffstat (limited to 'src/net_common.c')
-rw-r--r--src/net_common.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/src/net_common.c b/src/net_common.c
index 8af6b8d6..a89b1bba 100644
--- a/src/net_common.c
+++ b/src/net_common.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_common.c 264 2006-01-08 02:53:05Z fraggle $
+// $Id: net_common.c 268 2006-01-08 04:52:26Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -21,6 +21,9 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.3 2006/01/08 04:52:26 fraggle
+// Allow the server to reject clients
+//
// Revision 1.2 2006/01/08 02:53:05 fraggle
// Send keepalives if the connection is not doing anything else.
// Send all packets using a new NET_Conn_SendPacket to support this.
@@ -143,6 +146,18 @@ static void NET_Conn_ParseDisconnectACK(net_connection_t *conn,
}
}
+static void NET_Conn_ParseReject(net_connection_t *conn, net_packet_t *packet)
+{
+ if (conn->state == NET_CONN_STATE_CONNECTING)
+ {
+ // rejected by server
+
+ conn->state = NET_CONN_STATE_DISCONNECTED;
+
+ // there is a rejection message here, but it is unused at the moment.
+ }
+}
+
// Process a packet received by the server
//
// Returns true if eaten by common code
@@ -166,6 +181,9 @@ boolean NET_Conn_Packet(net_connection_t *conn, net_packet_t *packet,
case NET_PACKET_TYPE_KEEPALIVE:
// No special action needed.
break;
+ case NET_PACKET_TYPE_REJECTED:
+ NET_Conn_ParseReject(conn, packet);
+ break;
default:
// Not a common packet
@@ -219,33 +237,6 @@ void NET_Conn_Run(net_connection_t *conn)
NET_FreePacket(packet);
}
}
- else if (conn->state == NET_CONN_STATE_CONNECTING)
- {
- if (conn->last_send_time < 0
- || nowtime - conn->last_send_time > 1000)
- {
- // It has been a second since the last SYN was sent, and no
- // reply.
-
- if (conn->num_retries < MAX_RETRIES)
- {
- // send another SYN
-
- packet = NET_NewPacket(10);
- NET_WriteInt16(packet, NET_PACKET_TYPE_SYN);
- NET_WriteInt32(packet, NET_MAGIC_NUMBER);
- NET_Conn_SendPacket(conn, packet);
- NET_FreePacket(packet);
- conn->last_send_time = nowtime;
-
- ++conn->num_retries;
- }
- else
- {
- conn->state = NET_CONN_STATE_DISCONNECTED;
- }
- }
- }
else if (conn->state == NET_CONN_STATE_WAITING_ACK)
{
if (conn->last_send_time < 0