summaryrefslogtreecommitdiff
path: root/networksystem/networkclient.h
blob: 40f346790e8da1c3c1f0e4aac30b6dd372091b84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//===========================================================================//

#ifndef CLIENT_H
#define CLIENT_H
#ifdef _WIN32
#pragma once
#endif

#include "NetChannel.h"

class CNetworkClient : public IConnectionlessPacketHandler, public INetworkMessageHandler, public ILookupChannel
{
public:
	CNetworkClient();
	virtual ~CNetworkClient();

	bool	Init( int nListenPort );
	void	Shutdown();

	bool	Connect( const char *server, int port );
	void	Disconnect();

	// 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 INetChannel *FindNetChannel( const netadr_t& from ) ;

	INetChannel *GetNetChannel()
	{
		return &m_NetChan;
	}

	void ReadPackets();
	void SendUpdate();

	CUDPSocket *m_pSocket;
	
	CNetChannel		m_NetChan;
	bool			m_bConnected;
};

#endif // CLIENT_H