VANetClientImpl.h 2.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 *  --------------------------------------------------------------------------------------------
 *
 *    VVV        VVV A           Virtual Acoustics (VA) | http://www.virtualacoustics.org
 *     VVV      VVV AAA          Licensed under the Apache License, Version 2.0
 *      VVV    VVV   AAA
 *       VVV  VVV     AAA        Copyright 2015-2017
 *        VVVVVV       AAA       Institute of Technical Acoustics (ITA)
 *         VVVV         AAA      RWTH Aachen University
 *
 *  --------------------------------------------------------------------------------------------
 */

#ifndef IW_VANET_CLIENT_IMPL
#define IW_VANET_CLIENT_IMPL
Jonas Stienen's avatar
Jonas Stienen committed
16
17
18
19
20
21
22

#include <VANetClient.h>

#include <list>

class VistaConnectionIP;
class CVANetNetworkProtocol;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
23
class IVAEventHandler;
Jonas Stienen's avatar
Jonas Stienen committed
24
25
26
27
28
29
class VistaMutex;

/**
 * Thread-Safe implementation
 */

30
31
class CVANetClientImpl : public IVANetClient
{
Jonas Stienen's avatar
Jonas Stienen committed
32
33
34
35
public:
	CVANetClientImpl();
	~CVANetClientImpl();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
36
	IVAInterface* GetCoreInstance() const;
Jonas Stienen's avatar
Jonas Stienen committed
37
38
39

	bool IsConnected() const;
	std::string GetServerAddress() const;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
40
	int Initialize( const std::string& sServerAddress, const int iServerPort, const int iHeadChannelMode = VA_HC_USE_EXISTING, const int IExceptionHandlingMode = EXC_CLIENT_THROW, const bool bBufferSynchronizedCommands = true );
Jonas Stienen's avatar
Jonas Stienen committed
41
42
43
	int Disconnect();
	void SendConnectionEvent( int nId );

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
44
45
	void AttachCoreEventHandler( IVAEventHandler* pCoreEventHandler );
	void DetachCoreEventHandler( IVAEventHandler* pCoreEventHandler );
Jonas Stienen's avatar
Jonas Stienen committed
46

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
47
48
	virtual bool AttachEventHandler( IVANetClient::IEventHandler* pHandler );
	virtual bool DetachEventHandler( IVANetClient::IEventHandler* pHandler );
Jonas Stienen's avatar
Jonas Stienen committed
49

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
50
	virtual void SetExceptionHandlingMode( const int nMode );
Jonas Stienen's avatar
Jonas Stienen committed
51
	virtual int GetExceptionhandlingMode() const;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
52

Jonas Stienen's avatar
Jonas Stienen committed
53
54
55
56
	void ProcessNetEvent( int iEventID );
	void ProcessEventChannelError();

private:
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
57
	void Cleanup();
Jonas Stienen's avatar
Jonas Stienen committed
58
	void EmitEvent( const CEvent& oEvent );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
59
	void EmitEvent( const int iID );
Jonas Stienen's avatar
Jonas Stienen committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

protected:
	class CNetworkedVACore;
	class CNetworkedVACoreThreadSafe;
	CNetworkedVACore*	m_pVACore;

	class CEventReceiver;
	CEventReceiver*		m_pEventReceiver;

	CVANetNetworkProtocol*	m_pProtocol;

	bool				m_bConnected;
	bool				m_bShutdownFlag;

	VistaConnectionIP*	m_pCommandChannel;
	VistaConnectionIP*	m_pEventChannel;
	VistaConnectionIP*	m_pHeadChannel;

	std::string			m_sServerIP;

	std::list<IEventHandler*>	m_liEventHandlers;
	VistaMutex*			m_pEventChannelLock;
};

84
#endif// IW_VANET_CLIENT_IMPL