Commit 4361734a authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Compiling new API

parent 18e6f239
This diff is collapsed.
......@@ -41,8 +41,8 @@ public:
int Disconnect();
void SendConnectionEvent( int nId );
void AttachCoreEventHandler( IVAEventHandler* pCoreEventHandler );
void DetachCoreEventHandler( IVAEventHandler* pCoreEventHandler );
void AttachEventHandler( IVAEventHandler* pCoreEventHandler );
void DetachEventHandler( IVAEventHandler* pCoreEventHandler );
virtual bool AttachEventHandler( IVANetClient::IEventHandler* pHandler );
virtual bool DetachEventHandler( IVANetClient::IEventHandler* pHandler );
......
......@@ -140,8 +140,8 @@ void CVANetNetworkProtocol::ServerCallFunctionByMessageType( const int nMessageT
SERVER_FUNCTION_MAPPING( VA_NP_DELETE_SIGNALSOURCE, ServerDeleteSignalSource() );
SERVER_FUNCTION_MAPPING( VA_NP_GET_SIGNALSOURCE_INFO, ServerGetSignalSourceInfo() );
SERVER_FUNCTION_MAPPING( VA_NP_GET_SIGNALSOURCE_INFOS, ServerGetSignalSourceInfos() );
SERVER_FUNCTION_MAPPING( VA_NP_GET_AUDIOFILE_SIGNALSOURCE_PLAYSTATE, ServerGetAudiofileSignalSourcePlaybackState() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_AUDIOFILE_SIGNALSOURCE_PLAYACTION, ServerSetAudiofileSignalSourcePlaybackAction() );
SERVER_FUNCTION_MAPPING( VA_NP_GET_AUDIOFILE_SIGNALSOURCE_PLAYSTATE, ServerGetSignalSourceBufferPlaybackState() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_AUDIOFILE_SIGNALSOURCE_PLAYACTION, ServerSetSignalSourceBufferPlaybackAction() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_AUDIOFILE_SIGNALSOURCE_PLAYPOS, ServerSetAudiofileSignalSourcePlaybackPosition() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_AUDIOFILE_SIGNALSOURCE_LOOPING, ServerSetSignalSourceBufferLooping() );
SERVER_FUNCTION_MAPPING( VA_NP_GET_AUDIOFILE_SIGNALSOURCE_LOOPING, ServerGetSignalSourceBufferLooping() );
......@@ -212,7 +212,7 @@ void CVANetNetworkProtocol::ServerCallFunctionByMessageType( const int nMessageT
SERVER_FUNCTION_MAPPING( VA_NP_GET_PORTAL_NAME, ServerGetSoundPortalName() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_PORTAL_NAME, ServerSetSoundPortalName() );
SERVER_FUNCTION_MAPPING( VA_NP_GET_PORTAL_PARAMETERS, ServerGetSoundPortalParameters() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_PORTAL_STATE, ServerSetPortalParameters() );
SERVER_FUNCTION_MAPPING( VA_NP_SET_PORTAL_STATE, ServerSetSoundPortalParameters() );
// Global functions
SERVER_FUNCTION_MAPPING( VA_NP_GET_INPUT_GAIN, ServerGetInputGain() );
......@@ -962,7 +962,7 @@ void CVANetNetworkProtocol::ServerGetSignalSourceInfos()
pMsg->WriteSignalSourceInfo( vInfos[ i ] );
}
int CVANetNetworkProtocol::ClientGetAudiofileSignalSourcePlaybackState( const std::string& sSignalSourceID )
int CVANetNetworkProtocol::ClientGetSignalSourceBufferPlaybackState( const std::string& sSignalSourceID )
{
CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_AUDIOFILE_SIGNALSOURCE_PLAYSTATE, MESSAGE_WITH_ANSWER );
pMsg->WriteString( sSignalSourceID );
......@@ -971,7 +971,7 @@ int CVANetNetworkProtocol::ClientGetAudiofileSignalSourcePlaybackState( const st
return iPlayState;
}
void CVANetNetworkProtocol::ServerGetAudiofileSignalSourcePlaybackState()
void CVANetNetworkProtocol::ServerGetSignalSourceBufferPlaybackState()
{
CVANetMessage* pMsg = ServerGetMessage();
std::string sSignalSourceID = pMsg->ReadString();
......@@ -979,7 +979,7 @@ void CVANetNetworkProtocol::ServerGetAudiofileSignalSourcePlaybackState()
pMsg->WriteInt( iPlayState );
}
void CVANetNetworkProtocol::ClientSetAudiofileSignalSourcePlaybackAction( const std::string& sSignalSourceID, const int iPlayAction )
void CVANetNetworkProtocol::ClientSetSignalSourceBufferPlaybackAction( const std::string& sSignalSourceID, const int iPlayAction )
{
CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_AUDIOFILE_SIGNALSOURCE_PLAYACTION, MESSAGE_ALLOWS_BUFFERING );
pMsg->WriteString( sSignalSourceID );
......@@ -987,7 +987,7 @@ void CVANetNetworkProtocol::ClientSetAudiofileSignalSourcePlaybackAction( const
ClientSendCommand( pMsg );
}
void CVANetNetworkProtocol::ServerSetAudiofileSignalSourcePlaybackAction()
void CVANetNetworkProtocol::ServerSetSignalSourceBufferPlaybackAction()
{
CVANetMessage* pMsg = ServerGetMessage();
std::string sSignalSourceID = pMsg->ReadString();
......@@ -1028,7 +1028,7 @@ void CVANetNetworkProtocol::ServerGetSignalSourceBufferLooping()
pMsg->WriteBool( bLooping );
}
void CVANetNetworkProtocol::ClientSetAudiofileSignalSourcePlaybackPosition( const std::string& sSignalSourceID, const double dPlaybackPosition )
void CVANetNetworkProtocol::ClientSetSignalSourceBufferPlaybackPosition( const std::string& sSignalSourceID, const double dPlaybackPosition )
{
CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_AUDIOFILE_SIGNALSOURCE_PLAYPOS, MESSAGE_ALLOWS_BUFFERING );
pMsg->WriteString( sSignalSourceID );
......@@ -1089,10 +1089,7 @@ void CVANetNetworkProtocol::ServerGetSignalSourceParameters()
void CVANetNetworkProtocol::ClientLockUpdate()
{
ClientPrepareMessageBuffering();
CVANetMessage* pMsg = ClientInitMessage( VA_NP_LOCK_SCENE,
MESSAGE_ALLOWS_BUFFERING );
CVANetMessage* pMsg = ClientInitMessage( VA_NP_LOCK_SCENE, MESSAGE_ALLOWS_BUFFERING );
ClientSendCommand( pMsg );
}
......@@ -1101,7 +1098,7 @@ void CVANetNetworkProtocol::ServerLockUpdate()
m_pRealCore->LockUpdate();
}
int CVANetNetworkProtocol::ClientUnlockScene()
int CVANetNetworkProtocol::ClientUnlockUpdate()
{
if( m_bBufferingActive == false )
{
......@@ -1945,21 +1942,23 @@ void CVANetNetworkProtocol::ServerSetSoundReceiverDirectivity()
m_pRealCore->SetSoundReceiverDirectivity( iID, iDirectivity );
}
void CVANetNetworkProtocol::ClientCreateScene( const CVAStruct& oParams, const std::string& sName )
std::string CVANetNetworkProtocol::ClientCreateScene( const CVAStruct& oParams, const std::string& sName )
{
CVANetMessage* pMsg = ClientInitMessage( VA_NP_SCENE_CREATE, MESSAGE_ENFORCED_EXCEPTION );
CVANetMessage* pMsg = ClientInitMessage( VA_NP_SCENE_CREATE, MESSAGE_WITH_ANSWER );
pMsg->WriteVAStruct( oParams );
pMsg->WriteString( sName );
ClientSendCommand( pMsg );
return pMsg->ReadString();
}
std::string CVANetNetworkProtocol::ServerCreateScene()
void CVANetNetworkProtocol::ServerCreateScene()
{
CVANetMessage* pMsg = ServerGetMessage();
CVAStruct oParams;
pMsg->ReadVAStruct( oParams );
const std::string sName = pMsg->ReadString();
return m_pRealCore->CreateScene( oParams, sName );
const std::string sID = m_pRealCore->CreateScene( oParams, sName );
pMsg->WriteString( sID );
}
void CVANetNetworkProtocol::ClientGetSceneIDs( std::vector< std::string >& vsIDs )
......@@ -2123,7 +2122,7 @@ void CVANetNetworkProtocol::ServerGetSoundPortalName()
pMsg->WriteString( sName );
}
CVAStruct CVANetNetworkProtocol::ClientGetPortalParameters( const int iID )
CVAStruct CVANetNetworkProtocol::ClientGetSoundPortalParameters( const int iID )
{
CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_PORTAL_PARAMETERS, MESSAGE_WITH_ANSWER );
pMsg->WriteInt( iID );
......@@ -2149,7 +2148,7 @@ void CVANetNetworkProtocol::ClientSetSoundPortalParameters( const int iPortalID,
ClientSendCommand( pMsg );
}
void CVANetNetworkProtocol::ServerSetPortalParameters()
void CVANetNetworkProtocol::ServerSetSoundPortalParameters()
{
CVANetMessage* pMsg = ServerGetMessage();
int iPortalID = pMsg->ReadInt();
......
......@@ -341,6 +341,9 @@ public:
virtual void ClientGetModules( std::vector< CVAModuleInfo >& m_viModuleInfos );
virtual void ServerGetModules();
CVAStruct ClientGetSearchPaths();
void ServerGetSearchPaths();
virtual CVAStruct ClientCallModule( const std::string& sModuleName, const CVAStruct& oArgs );
virtual void ServerCallModule();
......@@ -356,6 +359,17 @@ public:
virtual void ClientGetDirectivityInfos( std::vector<CVADirectivityInfo>& vdiDest );
virtual void ServerGetDirectivityInfos();
void ClientSetDirectivityName( const int iID, const std::string& sName );
void ServerSetDirectivityName();
std::string ClientGetDirectivityName( const int iID );
void ServerGetDirectivityName();
virtual void ClientSetDirectivityParameters( const int iID, const CVAStruct& oParams );
virtual void ServerSetDirectivityParameters();
virtual CVAStruct ClientGetDirectivityParameters( const int iID, const CVAStruct& oParams );
virtual void ServerGetDirectivityParameters();
virtual std::string ClientCreateSignalSourceBufferFromParameters( const CVAStruct& oParams, const std::string& sName = "" );
virtual void ServerCreateSignalSourceBufferFromParameters();
......@@ -382,13 +396,13 @@ public:
virtual void ClientGetSignalSourceInfos( std::vector< CVASignalSourceInfo >& vssiDest );
virtual void ServerGetSignalSourceInfos();
virtual int ClientGetAudiofileSignalSourcePlaybackState( const std::string& sSignalSourceID );
virtual void ServerGetAudiofileSignalSourcePlaybackState();
virtual int ClientGetSignalSourceBufferPlaybackState( const std::string& sSignalSourceID );
virtual void ServerGetSignalSourceBufferPlaybackState();
virtual void ClientSetAudiofileSignalSourcePlaybackAction( const std::string& sSignalSourceID, const int iPlayState );
virtual void ServerSetAudiofileSignalSourcePlaybackAction();
virtual void ClientSetSignalSourceBufferPlaybackAction( const std::string& sSignalSourceID, const int iPlayState );
virtual void ServerSetSignalSourceBufferPlaybackAction();
virtual void ClientSetAudiofileSignalSourcePlaybackPosition( const std::string& sSignalSourceID, const double dPlaybackPosition );
virtual void ClientSetSignalSourceBufferPlaybackPosition( const std::string& sSignalSourceID, const double dPlaybackPosition );
virtual void ServerSetAudiofileSignalSourcePlaybackPosition();
virtual bool ClientGetSignalSourceBufferLooping( const std::string& );
......@@ -405,7 +419,7 @@ public:
virtual void ClientLockUpdate();
virtual void ServerLockUpdate();
virtual int ClientUnlockScene();
virtual int ClientUnlockUpdate();
virtual void ServerUnlockUpdate();
virtual bool ClientGetUpdateLocked();
......@@ -429,6 +443,9 @@ public:
virtual bool ClientGetSoundSourceEnabled( const int iID );
virtual void ServerGetSoundSourceEnabled();
CVASoundSourceInfo ClientGetSoundSourceInfo( const int iID );
void ServerGetSoundSourceInfo();
virtual std::string ClientGetSoundSourceName( const int iSoundSourceID );
virtual void ServerGetSoundSourceName();
virtual void ClientSetSoundSourceName( const int iSoundSourceID, const std::string& sName );
......@@ -547,8 +564,8 @@ public:
virtual void ServerSetSoundReceiverOrientationVU();
virtual void ClientCreateScene( const CVAStruct& oParams, const std::string& sName );
virtual std::string ServerCreateScene();
virtual std::string ClientCreateScene( const CVAStruct& oParams, const std::string& sName );
virtual void ServerCreateScene();
virtual void ClientGetSceneIDs( std::vector< std::string >& vsIDs );
virtual void ServerGetSceneIDs();
......@@ -575,11 +592,10 @@ public:
virtual void ClientSetPortalName( int iPortalID, const std::string& sName );
virtual void ServerSetSoundPortalName();
virtual CVAStruct ClientGetPortalParameters( const int iPortalID );
virtual CVAStruct ClientGetSoundPortalParameters( const int iPortalID );
virtual void ServerGetSoundPortalParameters();
virtual void ClientSetSoundPortalParameters( const int iPortalID, const CVAStruct& oParams );
virtual void ServerSetPortalParameters();
virtual void ServerSetSoundPortalParameters();
virtual double ClientGetCoreClock();
......
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
* 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
*
* ---------------------------------------------------------------------------------
*
* Datei: VANetServerImpl.cpp
*
* Zweck: Implementierung des Netzwerk-Servers fr den VA-Kernel
*
* Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de),
* Dominik Rausch (rausch@vr.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
* --------------------------------------------------------------------------------------------
*/
// $Id: VANetServerImpl.cpp 4589 2016-02-24 22:27:08Z stienen $
#include "VANetServerImpl.h"
#include "VANetNetworkProtocol.h"
#include "VANetMessage.h"
#include "VANetVistaCompatibility.h"
#include <VACoreEvent.h>
#include <VAException.h>
#include <VA.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
......@@ -193,7 +182,7 @@ public:
return true;
};
inline virtual bool LoopBody()
inline bool LoopBody()
{
int nUpdateID = m_oConnMultiplexer.Demultiplex();
if( nUpdateID == 0 )
......@@ -218,24 +207,29 @@ public:
m_mapConnections[ nUpdateID ]->SetWaitForDescriptorEventSelectIsEnabled( true );
}
}
#ifdef VANET_SERVER_VERBOSE
catch( CVAException& e )
{
#ifdef VANET_SERVER_VERBOSE
std::cerr << "VA Server: caught exception and will disconnect now (" << e << ")" << std::endl;
#endif
m_pParent->RemoveClient( m_mapConnections[ nUpdateID ], CVANetNetworkProtocol::VA_NET_SERVER_DISCONNECT );
}
#else
catch( CVAException& )
{
m_pParent->RemoveClient( m_mapConnections[ nUpdateID ], CVANetNetworkProtocol::VA_NET_SERVER_DISCONNECT );
}
#endif
return false;
};
inline virtual void PreLoop()
inline void PreLoop()
{
#ifdef VANET_SERVER_VERBOSE
std::cout << "VA Server: starting connection update loop" << std::endl;
#endif
};
inline virtual void PostRun()
inline void PostRun()
{
#ifdef VANET_SERVER_VERBOSE
std::cout << "VA Server: starting connection update loop" << std::endl;
......@@ -245,7 +239,7 @@ public:
private:
int m_iIDCounter;
std::map<int, VistaConnectionIP*> m_mapConnections;
std::map< int, VistaConnectionIP* > m_mapConnections;
CVANetServerImpl* m_pParent;
VistaIOHandleBasedIOMultiplexer m_oConnMultiplexer;
CVANetNetworkProtocol* m_pProtocol;
......@@ -255,11 +249,11 @@ private:
/**** class CEventHandler ****/
/***********************************************************************/
class CVANetServerImpl::CEventHandler : public IVACoreEventHandler
class CVANetServerImpl::CEventHandler : public IVAEventHandler
{
public:
inline CEventHandler( CVANetServerImpl* pParent, CVANetNetworkProtocol* pProtocol, VistaMutex* pEventChannelLock, IVACore* pRealCore )
: IVACoreEventHandler()
inline CEventHandler( CVANetServerImpl* pParent, CVANetNetworkProtocol* pProtocol, VistaMutex* pEventChannelLock, IVAInterface* pRealCore )
: IVAEventHandler()
, m_pProtocol( pProtocol )
, m_pEventChannelLock( pEventChannelLock )
, m_pRealCore( pRealCore )
......@@ -270,7 +264,7 @@ public:
inline ~CEventHandler()
{
m_pRealCore->DetachCoreEventHandler( this );
m_pRealCore->DetachEventHandler( this );
};
inline bool AddClientConnection( VistaConnectionIP* pConnection )
......@@ -284,7 +278,7 @@ public:
return false;
if( m_vecRegisteredClients.empty() )
m_pRealCore->AttachCoreEventHandler( this );
m_pRealCore->AttachEventHandler( this );
m_vecRegisteredClients.push_back( pConnection );
return true;
......@@ -293,26 +287,22 @@ public:
inline bool RemoveClientConnection( VistaConnectionIP* pConnection )
{
VistaMutexLock oLock( *m_pEventChannelLock );
std::vector<VistaConnectionIP*>::iterator itEntry = std::find(
m_vecRegisteredClients.begin(),
m_vecRegisteredClients.end(),
pConnection );
std::vector<VistaConnectionIP*>::iterator itEntry = std::find( m_vecRegisteredClients.begin(), m_vecRegisteredClients.end(), pConnection );
if( itEntry == m_vecRegisteredClients.end() )
return false;
m_vecRegisteredClients.erase( itEntry );
if( m_vecRegisteredClients.empty() )
m_pRealCore->DetachCoreEventHandler( this );
m_pRealCore->DetachEventHandler( this );
return true;
};
inline virtual void HandleVACoreEvent( const CVACoreEvent* pEvent )
inline void HandleVAEvent( const CVAEvent* pEvent )
{
VistaMutexLock oLock( *m_pEventChannelLock );
m_pProtocol->ServerPrepareEventMessage( pEvent, m_pMessage );
std::list<VistaConnectionIP*> liDeadConnections;
for( std::vector<VistaConnectionIP*>::iterator itCon = m_vecRegisteredClients.begin();
itCon != m_vecRegisteredClients.end(); ++itCon )
for( std::vector<VistaConnectionIP*>::iterator itCon = m_vecRegisteredClients.begin(); itCon != m_vecRegisteredClients.end(); ++itCon )
{
try
{
......@@ -321,24 +311,22 @@ public:
}
catch( VistaExceptionBase& oException )
{
std::cerr << "VANetServer: caught connection exception - "
<< oException.GetExceptionText() << std::endl;
std::cerr << "VANetServer: caught connection exception - " << oException.GetExceptionText() << std::endl;
liDeadConnections.push_back( ( *itCon ) );
}
catch( CVAException& oException )
{
std::cerr << "VANetServer: caught connection exception - "
<< oException.ToString() << std::endl;
std::cerr << "VANetServer: caught connection exception - " << oException.ToString() << std::endl;
liDeadConnections.push_back( ( *itCon ) );
}
}
for( std::list<VistaConnectionIP*>::iterator itDead = liDeadConnections.begin();
itDead != liDeadConnections.end(); ++itDead )
for( std::list<VistaConnectionIP*>::iterator itDead = liDeadConnections.begin(); itDead != liDeadConnections.end(); ++itDead )
{
m_pParent->RemoveClient( ( *itDead ), CVANetNetworkProtocol::VA_NET_SERVER_DISCONNECT );
}
if( pEvent->iEventID == CVACoreEvent::VA_COREEVENT_DESTROY ) {
if( pEvent->iEventID == CVAEvent::VA_EVENT_DESTROY )
{
// Important: Core instance was deleted. We should disable the server now
// TODO: Implement
}
......@@ -350,7 +338,7 @@ private:
std::vector<VistaConnectionIP*> m_vecRegisteredClients;
CVANetNetworkProtocol* m_pProtocol;
CVANetMessage* m_pMessage;
IVACore* m_pRealCore;
IVAInterface* m_pRealCore;
};
/***********************************************************************/
......@@ -453,7 +441,7 @@ int CVANetServerImpl::Finalize()
oLock.Lock();
if( m_pEventHandler )
m_pRealCore->DetachCoreEventHandler( m_pEventHandler );
m_pRealCore->DetachEventHandler( m_pEventHandler );
delete m_pEventHandler;
m_pEventHandler = NULL;
......@@ -497,31 +485,18 @@ int CVANetServerImpl::GetServerPort() const
return m_iServerPort;
}
IVACore* CVANetServerImpl::GetCoreInstance() const
IVAInterface* CVANetServerImpl::GetCoreInstance() const
{
return m_pRealCore;
}
void CVANetServerImpl::SetCoreInstance( IVACore* pCore ) {
void CVANetServerImpl::SetCoreInstance( IVAInterface* pCore )
{
m_pRealCore = pCore;
if( m_pProtocol )
m_pProtocol->SetRealVACore( pCore );
}
//bool CVANetServerImpl::IsActive() const {
// return m_bRunning;
//}
//
//void CVANetServerImpl::SetActive(bool bActive) {
// if( bActive == m_bRunning )
// return;
// if( bActive )
// m_pConnObserver->Resume();
// else
// m_pConnObserver->PauseThread();
// m_bRunning = bActive;
//}
bool CVANetServerImpl::IsClientConnected() const
{
return ( m_vecClients.empty() == false );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment