Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef CLIENT_H
  7. #define CLIENT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "NetChannel.h"
  12. class CNetworkClient : public IConnectionlessPacketHandler, public INetworkMessageHandler, public ILookupChannel
  13. {
  14. public:
  15. CNetworkClient();
  16. virtual ~CNetworkClient();
  17. bool Init( int nListenPort );
  18. void Shutdown();
  19. bool Connect( const char *server, int port );
  20. void Disconnect();
  21. // IConnectionlessPacketHandler
  22. virtual bool ProcessConnectionlessPacket( CNetPacket *packet ); // process a connectionless packet
  23. // INetworkMessageHandler
  24. virtual void OnConnectionClosing( INetChannel *channel, char const *reason );
  25. virtual void OnConnectionStarted( INetChannel *channel );
  26. virtual void OnPacketStarted( int inseq, int outseq );
  27. virtual void OnPacketFinished();
  28. // ILookupChannel
  29. virtual INetChannel *FindNetChannel( const netadr_t& from ) ;
  30. INetChannel *GetNetChannel()
  31. {
  32. return &m_NetChan;
  33. }
  34. void ReadPackets();
  35. void SendUpdate();
  36. CUDPSocket *m_pSocket;
  37. CNetChannel m_NetChan;
  38. bool m_bConnected;
  39. };
  40. #endif // CLIENT_H