ITANetAudioClient.cpp 1 KB
Newer Older
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1
#include "ITANetAudioClient.h"
2 3

#include <ITANetAudioStream.h>
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
4
#include <ITAException.h>
5 6 7

#include <VistaInterProcComm/Connections/VistaConnectionIP.h>

8 9
CITANetAudioClient::CITANetAudioClient()
	: m_pConnection( NULL )
10 11 12
{
}

13
CITANetAudioClient::~CITANetAudioClient()
14
{
15
	delete m_pConnection;
16 17
}

18
bool CITANetAudioClient::Connect( const std::string& sAddress, int iPort )
19
{
20
	if( GetIsConnected() )
21 22 23 24
		ITA_EXCEPT1( MODAL_EXCEPTION, "This net stream is already connected" );

	// Attempt to connect and check parameters
	m_pConnection = new VistaConnectionIP( VistaConnectionIP::CT_TCP, sAddress, iPort );
25
	
26
	if( !GetIsConnected() )
27 28 29 30 31
	{
		delete m_pConnection;
		m_pConnection = NULL;
		return false;
	}
32 33

	return true;
34 35
}

36
VistaConnectionIP* CITANetAudioClient::GetConnection() const
37
{
38
	return m_pConnection;
39 40
}

41
void CITANetAudioClient::Disconnect()
42
{
43 44
	delete m_pConnection;
	m_pConnection = NULL;
45 46
}

47
bool CITANetAudioClient::GetIsConnected() const
48
{
49 50 51 52
	if( m_pConnection )
		return m_pConnection->GetIsOpen();
	else
		return false;
53
}