ITANetAudioClient.cpp 1.14 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, const int iPort, const bool bUseUDP /* = false */ )
19
{
20
	if( GetIsConnected() )
21 22 23
		ITA_EXCEPT1( MODAL_EXCEPTION, "This net stream is already connected" );

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

	return true;
35 36
}

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

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

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