summaryrefslogtreecommitdiff
path: root/networksystem/networkserver.h
diff options
context:
space:
mode:
Diffstat (limited to 'networksystem/networkserver.h')
-rw-r--r--networksystem/networkserver.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/networksystem/networkserver.h b/networksystem/networkserver.h
new file mode 100644
index 0000000..bd88b5b
--- /dev/null
+++ b/networksystem/networkserver.h
@@ -0,0 +1,86 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//===========================================================================//
+
+#ifndef NETWORKSERVER_H
+#define NETWORKSERVER_H
+
+#include "networksystem/inetworksystem.h"
+#include "netchannel.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CPlayer;
+
+
+//-----------------------------------------------------------------------------
+// Server class
+//-----------------------------------------------------------------------------
+class CNetworkServer : public IConnectionlessPacketHandler, public INetworkMessageHandler, public ILookupChannel
+{
+public:
+ CNetworkServer( );
+ virtual ~CNetworkServer();
+
+ bool Init( int nServerPort );
+ void Shutdown();
+
+ // IConnectionlessPacketHandler
+ virtual bool ProcessConnectionlessPacket( CNetPacket *packet ); // process a connectionless packet
+
+ // INetworkMessageHandler
+ virtual void OnConnectionClosing( INetChannel *channel, char const *reason );
+ virtual void OnConnectionStarted( INetChannel *channel );
+
+ virtual void OnPacketStarted( int inseq, int outseq );
+ virtual void OnPacketFinished();
+
+ // ILookupChannel
+ virtual CNetChannel *FindNetChannel( const netadr_t& from ) ;
+
+ void ReadPackets();
+ void SendUpdates();
+ void AcceptConnection( const netadr_t& remote );
+
+ CPlayer *FindPlayerByAddress( const netadr_t& adr );
+ CPlayer *FindPlayerByNetChannel( INetChannel *chan );
+
+ CUDPSocket *m_pSocket;
+
+ CUtlVector< CPlayer * > m_Players;
+};
+
+
+//-----------------------------------------------------------------------------
+// Represents a connected player to the server
+//-----------------------------------------------------------------------------
+class CPlayer
+{
+public:
+ CPlayer( CNetworkServer *server, netadr_t& remote );
+
+ void SendUpdate();
+
+ const netadr_t &GetRemoteAddress()
+ {
+ return m_NetChan.GetRemoteAddress();
+ }
+
+ char const *GetName()
+ {
+ return "Foozle";
+ }
+
+ void Shutdown();
+
+ CNetChannel m_NetChan;
+ bool m_bMarkedForDeletion;
+};
+
+
+#endif // NETWORKSERVER_H
+