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

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
14
#include "VANetNetworkProtocol.h"
Jonas Stienen's avatar
Jonas Stienen committed
15
16
17
18
19
20

#include "VANetServerImpl.h"
#include "VANetClientImpl.h"
#include "VANetMessage.h"
#include "VANetVistaCompatibility.h"

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
21
#include <VA.h>
Jonas Stienen's avatar
Jonas Stienen committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <VistaBase/VistaExceptionBase.h>
#include <VistaInterProcComm/Connections/VistaByteBufferSerializer.h>
#include <VistaInterProcComm/Connections/VistaByteBufferDeSerializer.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>

#include <assert.h>
#include <sstream>


//////////////////////////////////////////////////
//////////       Main Implementation     /////////
//////////////////////////////////////////////////

CVANetNetworkProtocol::CVANetNetworkProtocol()
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	: m_pRealCore( NULL )
	, m_pServer( NULL )
	, m_pClient( NULL )
	, m_pLastAnswerConnection( NULL )
	, m_pCommandChannel( NULL )
	, m_pHeadChannel( NULL )
	, m_oIncomingEvent()
	, m_vecEventBuffer( 128 )
	, m_iReceiveTimeout( 0 )
	, m_iExceptionHandlingMode( IVANetClient::EXC_CLIENT_THROW )
	, m_bBufferingActive( false )
	, m_bBufferSynchronisedModification( false )
	, m_pMessage( NULL )
	, m_pBufferedMessage( NULL )
	, m_nCurrentMessageMode( MESSAGE_WITH_ANSWER )
	, m_pEventMessage( NULL )
Jonas Stienen's avatar
Jonas Stienen committed
53
54
{
}
55

Jonas Stienen's avatar
Jonas Stienen committed
56
57
58
59
60
61
62
63
64
CVANetNetworkProtocol::~CVANetNetworkProtocol()
{
	if( m_pLastAnswerConnection )
		m_pLastAnswerConnection->WaitForSendFinish();

	delete m_pMessage;
	delete m_pBufferedMessage;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
65
bool CVANetNetworkProtocol::InitializeAsClient( CVANetClientImpl* pClient, VistaConnectionIP* pCommandChannel, VistaConnectionIP* pHeadChannel, const int iExceptionhandlingmode, const bool bBufferSynchronisedModification )
Jonas Stienen's avatar
Jonas Stienen committed
66
67
68
69
70
71
{
	m_iExceptionHandlingMode = iExceptionhandlingmode;
	m_bBufferSynchronisedModification = bBufferSynchronisedModification;
	m_pClient = pClient;
	m_pCommandChannel = pCommandChannel;
	m_pHeadChannel = pHeadChannel;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
72

Jonas Stienen's avatar
Jonas Stienen committed
73
74
75
	m_pMessage = new CVANetMessage( m_pCommandChannel->GetByteorderSwapFlag() );
	m_pBufferedMessage = new CVANetMessage( m_pCommandChannel->GetByteorderSwapFlag() );
	m_pEventMessage = new CVANetMessage( m_pCommandChannel->GetByteorderSwapFlag() );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
76

Jonas Stienen's avatar
Jonas Stienen committed
77
78
79
80
81
82
83
84
85
86
87
88
89
	SetExceptionHandlingMode( m_iExceptionHandlingMode );
	return true;
}

bool CVANetNetworkProtocol::InitializeAsServer( CVANetServerImpl* pServer )
{
	m_pServer = pServer;

	m_pMessage = new CVANetMessage( VistaSerializingToolset::DOES_NOT_SWAP_MULTIBYTE_VALUES );
	m_pEventMessage = new CVANetMessage( VistaSerializingToolset::DOES_NOT_SWAP_MULTIBYTE_VALUES );
	return true;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
90
void CVANetNetworkProtocol::SetExceptionHandlingMode( const int nMode )
Jonas Stienen's avatar
Jonas Stienen committed
91
92
{
	m_iExceptionHandlingMode = nMode;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
93
}
94

Jonas Stienen's avatar
Jonas Stienen committed
95
96
97
98
99
int CVANetNetworkProtocol::GetExceptionHandlingMode() const
{
	return m_iExceptionHandlingMode;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
100
void CVANetNetworkProtocol::SetRealVACore( IVAInterface* pCore )
Jonas Stienen's avatar
Jonas Stienen committed
101
102
103
104
105
106
107
{
	m_pRealCore = pCore;
}

#define SERVER_FUNCTION_MAPPING(ID,FUNCTION) case (ID): { FUNCTION; break; }
//#define SERVER_FUNCTION_MAPPING(ID,FUNCTION) case (ID): { std::cout << "Processing " << #ID << std::endl; FUNCTION; break; }

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
108
void CVANetNetworkProtocol::ServerCallFunctionByMessageType( const int nMessageType, VistaConnectionIP* pConnection )
Jonas Stienen's avatar
Jonas Stienen committed
109
110
111
112
{
	switch( nMessageType )
	{
		SERVER_FUNCTION_MAPPING( VA_NP_GET_VERSION_INFO, ServerGetVersionInfo() );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
113

Jonas Stienen's avatar
Jonas Stienen committed
114
115
116
117
118
119
120
		// Base functions		
		SERVER_FUNCTION_MAPPING( VA_NP_GET_STATE, ServerGetState() );
		SERVER_FUNCTION_MAPPING( VA_NP_INITIALIZE, ServerInitialize() );
		SERVER_FUNCTION_MAPPING( VA_NP_FINALIZE, ServerFinalize() );
		SERVER_FUNCTION_MAPPING( VA_NP_RESET, ServerReset() );

		// Module interface
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
121
		SERVER_FUNCTION_MAPPING( VA_NP_GET_MODULES, ServerGetModules() );
Jonas Stienen's avatar
Jonas Stienen committed
122
		SERVER_FUNCTION_MAPPING( VA_NP_CALL_MODULE, ServerCallModule() );
123
124
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SEARCH_PATHS, ServerGetSearchPaths() );
		SERVER_FUNCTION_MAPPING( VA_NP_FIND_FILE_PATH, ServerFindFilePath() );
125
126
127
		SERVER_FUNCTION_MAPPING( VA_NP_GET_CORE_CONFIGURATION, ServerGetCoreConfiguration() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HARDWARE_CONFIGURATION, ServerGetHardwareConfiguration() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_FILE_LIST, ServerGetFileList() );
Jonas Stienen's avatar
Jonas Stienen committed
128
129

		// Event handling
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
130
131
		SERVER_FUNCTION_MAPPING( VA_NP_ATTACH_EVENT_HANDLER, ServerAttachEventHandler( pConnection ) );
		SERVER_FUNCTION_MAPPING( VA_NP_DETACH_EVENT_HANDLER, ServerDetachEventHandler( pConnection ) );
Jonas Stienen's avatar
Jonas Stienen committed
132
133

		// Directivities
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
134
135
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_DIRECTIVITY, ServerCreateDirectivityFromParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_DELETE_DIRECTIVITY, ServerDeleteDirectivity() );
Jonas Stienen's avatar
Jonas Stienen committed
136
137
		SERVER_FUNCTION_MAPPING( VA_NP_GET_DIRECTIVITY_INFO, ServerGetDirectivityInfo() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_DIRECTIVITY_INFOS, ServerGetDirectivityInfos() );
138
		SERVER_FUNCTION_MAPPING( VA_NP_GET_DIRECTIVITY_PARAMETERS, ServerGetDirectivityParameters() );
139
		SERVER_FUNCTION_MAPPING( VA_NP_SET_DIRECTIVITY_PARAMETERS, ServerSetDirectivityParameters() );
140
141
		SERVER_FUNCTION_MAPPING( VA_NP_GET_DIRECTIVITY_NAME, ServerGetDirectivityName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_DIRECTIVITY_NAME, ServerSetDirectivityName() );
Jonas Stienen's avatar
Jonas Stienen committed
142
143

		// Signal sources
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
144
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_BUFFER_FROM_PARAMETERS, ServerCreateSignalSourceBufferFromParameters() );
145
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_TEXT_TO_SPEECH, ServerCreateTextToSpeechSignalSource() );
146
147
148
149
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_SEQUENCER, ServerCreateSequencerSignalSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_NETWORK_STREAM, ServerCreateNetworkStreamSignalSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_ENGINE, ServerCreateEngineSignalSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_MACHINE, ServerCreateSignalSourceMachine() );
150
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SIGNAL_SOURCE_PROTOTYPE_FROM_PARAMETERS, ServerCreateSignalSourcePrototypeFromParameters() );
Jonas Stienen's avatar
Jonas Stienen committed
151
152
153
		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() );
154
155
156
157
158
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SIGNAL_SOURCE_BUFFER_PLAYBACK_STATE, ServerGetSignalSourceBufferPlaybackState() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SIGNAL_SOURCE_BUFFER_PLAYBACK_ACTION, ServerSetSignalSourceBufferPlaybackAction() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SIGNAL_SOURCE_BUFFER_PLAYBACK_POSITION, ServerSetAudiofileSignalSourcePlaybackPosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SIGNAL_SOURCE_BUFFER_LOOPING, ServerSetSignalSourceBufferLooping() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SIGNAL_SOURCE_BUFFER_LOOPING, ServerGetSignalSourceBufferLooping() );
159
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SIGNAL_SOURCE_PARAMETERS, ServerGetSignalSourceParameters() );
Jonas Stienen's avatar
Jonas Stienen committed
160
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SIGNALSOURCE_PARAMETERS, ServerSetSignalSourceParameters() );
161
162
163
		SERVER_FUNCTION_MAPPING( VA_NP_ADD_SIGNAL_SOURCE_SEQUENCER_SAMPLE, ServerAddSignalSourceSequencerSample() );
		SERVER_FUNCTION_MAPPING( VA_NP_ADD_SIGNAL_SOURCE_SEQUENCER_PLAYBACK, ServerAddSignalSourceSequencerPlayback() );
		SERVER_FUNCTION_MAPPING( VA_NP_REMOVE_SIGNAL_SOURCE_SEQUENCER_SAMPLE, ServerRemoveSignalSourceSequencerSample() );
Jonas Stienen's avatar
Jonas Stienen committed
164
165

		// Synchronization functions
166
167
168
		SERVER_FUNCTION_MAPPING( VA_NP_LOCK_UPDATE, ServerLockUpdate() );
		SERVER_FUNCTION_MAPPING( VA_NP_UNLOCK_UPDATE, ServerUnlockUpdate() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_UPDATE_LOCKED, ServerGetUpdateLocked() );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
169

Jonas Stienen's avatar
Jonas Stienen committed
170
171
		// Sound sources
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_IDS, ServerGetSoundSourceIDs() );
172
173
174
175
176
177
178
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SOUND_SOURCE, ServerCreateSoundSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SOUND_SOURCE_EXPLICIT_RENDERER, ServerCreateSoundSourceExplicitRenderer() );
		SERVER_FUNCTION_MAPPING( VA_NP_DELETE_SOUND_SOURCE, ServerDeleteSoundSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_ENABLED, ServerSetSoundSourceEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_ENABLED, ServerGetSoundSourceEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_NAME, ServerSetSoundSourceName() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_NAME, ServerGetSoundSourceName() );
179
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_SIGNALSOURCE, ServerSetSoundSourceSignalSource() );
180
181
182
183
184
185
186
187
188
189
190
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_SIGNALSOURCE, ServerGetSoundSourceSignalSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_AURAMODE, ServerSetSoundSourceAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_AURAMODE, ServerGetSoundSourceAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_PARAMETERS, ServerSetSoundSourceParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_PARAMETERS, ServerGetSoundSourceParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_DIRECTIVITY, ServerSetSoundSourceDirectivity() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_DIRECTIVITY, ServerGetSoundSourceDirectivity() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_SOUND_POWER, ServerSetSoundSourceSoundPower() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_SOUND_POWER, ServerGetSoundSourceSoundPower() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_MUTED, ServerSetSoundSourceMuted() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_MUTED, ServerGetSoundSourceMuted() );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
191
192
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_POSE, ServerSetSoundSourcePose() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_POSE, ServerGetSoundSourcePose() );
193
194
195
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_POSITION, ServerSetSoundSourcePosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_POSITION, ServerGetSoundSourcePosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_ORIENTATION, ServerSetSoundSourceOrientation() );
196
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_ORIENTATION, ServerGetSoundSourceOrientation() );
197
198
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_ORIENTATION_VU, ServerSetSoundSourceOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_ORIENTATION_VU, ServerGetSoundSourceOrientationVU() );
199
200
201
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_INFO, ServerGetSoundSourceInfo() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_GEOMETRY_MESH, ServerGetSoundSourceGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_GEOMETRY_MESH, ServerGetSoundSourceGeometryMesh() );
Jonas Stienen's avatar
Jonas Stienen committed
202

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
203
		// SoundReceivers
204
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_IDS, ServerGetSoundReceiverIDs() );
205
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_INFO, ServerGetSoundReceiverInfo() );
206
207
208
209
210
211
212
213
214
215
216
217
218
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SOUND_RECEIVER, ServerCreateSoundReceiver() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SOUND_RECEIVER_EXPLICIT_RENDERER, ServerCreateSoundReceiverExplicitRenderer() );
		SERVER_FUNCTION_MAPPING( VA_NP_DELETE_SOUND_RECEIVER, ServerDeleteSoundReceiver() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_ENABLED, ServerSetSoundReceiverEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_ENABLED, ServerGetSoundReceiverEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_NAME, ServerGetSoundReceiverName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_NAME, ServerSetSoundReceiverName() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_AURALIZATION_MODE, ServerGetSoundReceiverAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_AURALIZATION_MODE, ServerSetSoundReceiverAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_PARAMETERS, ServerSetSoundReceiverParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_PARAMETERS, ServerGetSoundReceiverParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_DIRECTIVITY, ServerGetSoundReceiverDirectivity() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_DIRECTIVITY, ServerSetSoundReceiverDirectivity() );
219
220
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_POSE, ServerSetSoundReceiverPose() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_POSE, ServerGetSoundReceiverPose() );
221
222
223
224
225
226
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_POSITION, ServerSetSoundReceiverPosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_POSITION, ServerGetSoundReceiverPosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_ORIENTATION, ServerSetSoundReceiverOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_ORIENTATION, ServerGetSoundReceiverOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_ORIENTATION_VU, ServerSetSoundReceiverOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_ORIENTATION_VU, ServerGetSoundReceiverOrientationVU() );
227
228
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_HEAD_ABOVE_TORSO_ORIENTATION, ServerSetSoundReceiverHeadAboveTorsoOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_HEAD_ABOVE_TORSO_ORIENTATION, ServerGetSoundReceiverHeadAboveTorsoOrientation() );
229
230
231
232
233
234
235
236
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_REAL_WORLD_POSITION_ORIENTATION_VU, ServerSetSoundReceiverRealWorldPositionOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_REAL_WORLD_POSITION_ORIENTATION_VU, ServerGetSoundReceiverRealWorldPositionOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_GEOMETRY_MESH, ServerSetSoundReceiverGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_GEOMETRY_MESH, ServerGetSoundReceiverGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_REAL_WORLD_POSE, ServerSetSoundReceiverRealWorldPose() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_REAL_WORLD_POSE, ServerGetSoundReceiverRealWorldPose() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_REAL_WORLD_TORSO_ORIENTATION, ServerSetSoundReceiverRealWorldTorsoOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_REAL_WORLD_TORSO_ORIENTATION, ServerGetSoundReceiverRealWorldTorsoOrientation() );
Jonas Stienen's avatar
Jonas Stienen committed
237
238

		// Scene
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
239
240
		SERVER_FUNCTION_MAPPING( VA_NP_SCENE_CREATE, ServerCreateScene() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SCENE_IDS, ServerGetSceneIDs() );
Jonas Stienen's avatar
Jonas Stienen committed
241
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SCENE_INFO, ServerGetSceneInfo() );
242
243
244
245
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SCENE_NAME, ServerGetSceneName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SCENE_NAME, ServerGetSceneName() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SCENE_ENABLED, ServerGetSceneEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SCENE_ENABLED, ServerGetSceneEnabled() );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
246

247
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SOUND_PORTAL, ServerCreateSoundPortal() );
248
249
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_NAME, ServerGetSoundPortalName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_NAME, ServerSetSoundPortalName() );
250
251
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_IDS, ServerGetSoundPortalIDs() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_INFO, ServerGetSoundPortalInfo() );
252
253
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_PARAMETERS, ServerGetSoundPortalParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_PARAMETERS, ServerSetSoundPortalParameters() );
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_POSITION, ServerGetSoundPortalPosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_POSITION, ServerSetSoundPortalPosition() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_ORIENTATION, ServerGetSoundPortalOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_ORIENTATION, ServerSetSoundPortalOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_ENABLED, ServerGetSoundPortalEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_ENABLED, ServerSetSoundPortalEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_MATERIAL, ServerGetSoundPortalMaterial() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_MATERIAL, ServerSetSoundPortalMaterial() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_NEXT_SOUND_PORTAL, ServerGetSoundPortalNextPortal() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_NEXT_SOUND_PORTAL, ServerSetSoundPortalNextPortal() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_SOUND_SOURCE, ServerGetSoundPortalSoundSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_SOUND_SOURCE, ServerSetSoundPortalSoundSource() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_SOUND_RECEIVER, ServerGetSoundPortalSoundReceiver() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_SOUND_RECEIVER, ServerSetSoundPortalSoundReceiver() );

		// Geometry meshes
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_GEOMETRY_MESH, ServerCreateGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_GEOMETRY_MESH_FROM_PARAMETERS, ServerCreateGeometryMeshFromParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_DELETE_GEOMETRY_MESH, ServerDeleteGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_GEOMETRY_MESH, ServerGetGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_GEOMETRY_MESH_IDS, ServerGetGeometryMeshIDs() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_GEOMETRY_MESH_PARAMETERS, ServerGetGeometryMeshParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_GEOMETRY_MESH_PARAMETERS, ServerSetGeometryMeshParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_GEOMETRY_MESH_NAME, ServerGetGeometryMeshName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_GEOMETRY_MESH_NAME, ServerSetGeometryMeshEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_GEOMETRY_MESH_ENABLED, ServerGetGeometryMeshEnabled() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_GEOMETRY_MESH_ENABLED, ServerSetGeometryMeshEnabled() );

		// Acoustic materials
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_ACOUSTIC_MATERIAL, ServerCreateAcousticMaterial() );
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_ACOUSTIC_MATERIAL_FROM_PARAMETERS, ServerCreateAcousticMaterialFromParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_DELETE_ACOUSTIC_MATERIAL, ServerDeleteAcousticMaterial() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_ACOUSTIC_MATERIAL_INFO, ServerGetAcousticMaterialInfo() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_ACOUSTIC_MATERIAL_INFOS, ServerGetAcousticMaterialInfos() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_ACOUSTIC_MATERIAL_NAME, ServerGetAcousticMaterialName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_ACOUSTIC_MATERIAL_NAME, ServerSetAcousticMaterialName() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_ACOUSTIC_MATERIAL_PARAMETERS, ServerGetAcousticMaterialParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_ACOUSTIC_MATERIAL_PARAMETERS, ServerSetAcousticMaterialParameters() );
Jonas Stienen's avatar
Jonas Stienen committed
292

293
294
295
296
297
298
299
300
301
302
303
304
305
306
		// Medium
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HOMOGENEOUS_MEDIUM_SOUND_SPEED, ServerGetHomogeneousMediumSoundSpeed() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_HOMOGENEOUS_MEDIUM_SOUND_SPEED, ServerSetHomogeneousMediumSoundSpeed() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HOMOGENEOUS_MEDIUM_TEMPERATURE, ServerGetHomogeneousMediumTemperature() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_HOMOGENEOUS_MEDIUM_TEMPERATURE, ServerSetHomogeneousMediumTemperature() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HOMOGENEOUS_MEDIUM_STATIC_PRESSURE, ServerGetHomogeneousMediumStaticPressure() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_HOMOGENEOUS_MEDIUM_STATIC_PRESSURE, ServerSetHomogeneousMediumStaticPressure() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HOMOGENEOUS_MEDIUM_RELATIVE_HUMIDITY, ServerGetHomogeneousMediumRelativeHumidity() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_HOMOGENEOUS_MEDIUM_RELATIVE_HUMIDITY, ServerSetHomogeneousMediumRelativeHumidity() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HOMOGENEOUS_MEDIUM_SHIFT_SPEED, ServerGetHomogeneousMediumShiftSpeed() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_HOMOGENEOUS_MEDIUM_SHIFT_SPEED, ServerSetHomogeneousMediumShiftSpeed() );;
		SERVER_FUNCTION_MAPPING( VA_NP_GET_HOMOGENEOUS_MEDIUM_PARAMETERS, ServerGetHomogeneousMediumParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_HOMOGENEOUS_MEDIUM_PARAMETERS, ServerSetHomogeneousMediumParameters() );

Jonas Stienen's avatar
Jonas Stienen committed
307
308
309
		// Global functions
		SERVER_FUNCTION_MAPPING( VA_NP_GET_INPUT_GAIN, ServerGetInputGain() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_INPUT_GAIN, ServerSetInputGain() );
310
		SERVER_FUNCTION_MAPPING( VA_NP_GET_INPUT_MUTED, ServerGetInputMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
311
312
313
		SERVER_FUNCTION_MAPPING( VA_NP_SET_INPUT_MUTED, ServerSetInputMuted() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_OUTPUT_GAIN, ServerGetOutputGain() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_OUTPUT_GAIN, ServerSetOutputGain() );
314
		SERVER_FUNCTION_MAPPING( VA_NP_GET_OUTPUT_MUTED, ServerGetOutputMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
315
316
317
318
319
320
321
322
323
324
		SERVER_FUNCTION_MAPPING( VA_NP_SET_OUTPUT_MUTED, ServerSetOutputMuted() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_GLOBAL_AURALIZATION_MODE, ServerGetGlobalAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_GLOBAL_AURALIZATION_MODE, ServerSetGlobalAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_CORE_CLOCK, ServerGetCoreClock() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_CORE_CLOCK, ServerSetCoreClock() );
		SERVER_FUNCTION_MAPPING( VA_NP_SUBSTITUTE_MACROS, ServerSubstituteMacros() );

		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_GET_INFOS, ServerGetRenderingModuleInfos() );
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_GET_GAIN, ServerGetRenderingModuleGain() );
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_SET_GAIN, ServerSetRenderingModuleGain() );
325
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_GET_MUTED, ServerGetRenderingModuleMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
326
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_SET_MUTED, ServerSetRenderingModuleMuted() );
327
328
329
330
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_GET_PARAMETERS, ServerGetRenderingModuleParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_SET_PARAMETERS, ServerSetRenderingModuleParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_GET_AURALIZATION_MODE, ServerGetRenderingModuleAuralizationMode() );
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_SET_AURALIZATION_MODE, ServerSetRenderingModuleAuralizationMode() );
Jonas Stienen's avatar
Jonas Stienen committed
331
332
333
334

		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_GET_INFOS, ServerGetReproductionModuleInfos() );
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_GET_GAIN, ServerGetReproductionModuleGain() );
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_SET_GAIN, ServerSetReproductionModuleGain() );
335
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_GET_MUTED, ServerGetReproductionModuleMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
336
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_SET_MUTED, ServerSetReproductionModuleMuted() );
337
338
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_GET_PARAMETERS, ServerGetReproductionModuleParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_SET_PARAMETERS, ServerSetReproductionModuleParameters() );
Jonas Stienen's avatar
Jonas Stienen committed
339

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
340
341
342
343
344
345
346
347
	case VA_NP_INVALID:
	default:
	{
		/** @todo: disconnect */
		std::ostringstream oStream;
		oStream << "VANetServer: Unkown Message Type " << nMessageType;
		VA_EXCEPT2( PROTOCOL_ERROR, oStream.str() );
	}
Jonas Stienen's avatar
Jonas Stienen committed
348
349
	}
}
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
350

Jonas Stienen's avatar
Jonas Stienen committed
351
352
bool CVANetNetworkProtocol::ProcessMessageFromClient( VistaConnectionIP* pConnection )
{
353
354
355
356
357
	
#ifdef VANET_NETWORK_COM_PRINT_DEBUG_INFOS
	std::cout << "[ VANetProtocol ][ DEBUG ] Processing message from client" << std::endl;
#endif

Jonas Stienen's avatar
Jonas Stienen committed
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
	assert( m_pRealCore != NULL );

	// just to avoid false connection notifies - these can happen
	if( pConnection->PendingDataSize() == 0 )
		return true;

	// Falls wir zuletzt eine Antwort gesendet haben, mssen wir nun warten,
	// bis das senden abgeschlossen ist, bevor wir die message leeren
	if( m_pLastAnswerConnection != NULL )
		m_pLastAnswerConnection->WaitForSendFinish();

	try
	{
		m_pMessage->ResetMessage();
		m_pMessage->SetConnection( pConnection );
		m_pMessage->ReadMessage();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
374
	}
Jonas Stienen's avatar
Jonas Stienen committed
375
376
	catch( VistaExceptionBase& oException )
	{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
377
		std::cerr << "VANetNetworkProtocol: caught connection exception - "
Jonas Stienen's avatar
Jonas Stienen committed
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
			<< oException.GetExceptionText() << std::endl;
		return false;
	}

	int nMessageType = m_pMessage->GetMessageType();

	// we assume an answer - if an exception occurs, or no answer is
	// sent, the value will be rewritten
	m_pMessage->SetAnswerType( VA_NP_SPECIAL_ANSWER );

	// Es kann eine gebufferete Nachricht kommen.
	// In dem fall mssen wir mehrfach Befehle parsen
	// dies tun wir, bis der MessageBuffer leer ist
	try
	{
		if( nMessageType == VA_NP_SPECIAL_BUFFERED_MESSAGE )
		{
			while( m_pMessage->GetIncomingMessageSize() > 0 )
			{
				nMessageType = m_pMessage->ReadInt();
				ServerCallFunctionByMessageType( nMessageType, pConnection );
			}
		}
		else if( nMessageType == VA_NP_SPECIAL_CLIENT_EVENT )
		{
			int nEventID = m_pMessage->ReadInt();
			m_pServer->HandleClientEvent( nEventID, pConnection );
			return true;
		}
		else
		{
			ServerCallFunctionByMessageType( nMessageType, pConnection );
		}
	}
	catch( CVAException& oException )
	{
		if( oException.GetErrorCode() == CVAException::PROTOCOL_ERROR )
			throw;

		switch( m_pMessage->GetExceptionMode() )
		{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
419
420
421
422
423
424
425
426
427
428
429
430
431
		case IVANetClient::EXC_CLIENT_THROW:
		{
			m_pMessage->SetAnswerType( VA_NP_SPECIAL_EXCEPTION );
			m_pMessage->WriteException( oException );
			m_pMessage->WriteAnswer();
			return true;
		}
		case IVANetClient::EXC_SERVER_PRINT:
		{
			std::cerr << "[IVANetServer]: Caught and swallowed exception :\n"
				<< oException.ToString() << std::endl;
			return true;
		}
Jonas Stienen's avatar
Jonas Stienen committed
432
433
434
435
436
437
438
439
440
441
442
443
444
		}
	}

	if( m_pMessage->GetOutgoingMessageHasData() )
	{
		m_pMessage->WriteAnswer();
	}
	else if( m_pMessage->GetExceptionMode() == IVANetClient::EXC_CLIENT_THROW )
	{
		m_pMessage->SetAnswerType( VA_NP_SPECIAL_NO_EXCEPTION );
		m_pMessage->WriteAnswer();
	}

445
446
447
448
#ifdef VANET_NETWORK_COM_PRINT_DEBUG_INFOS
	std::cout << "[ VANetProtocol ][ DEBUG ] Processing has successfully processed messagew from client" << std::endl;
#endif

Jonas Stienen's avatar
Jonas Stienen committed
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
	return true;
}

bool CVANetNetworkProtocol::GetBufferSynchronisedModification() const
{
	return m_bBufferSynchronisedModification;
}

void CVANetNetworkProtocol::SetBufferSynchronisedModifications( const bool bSet )
{
	m_bBufferSynchronisedModification = bSet;
}

void CVANetNetworkProtocol::ClientPrepareMessageBuffering()
{
	if( m_bBufferSynchronisedModification == false )
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
465
		return;
Jonas Stienen's avatar
Jonas Stienen committed
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483

	// @todo: how to handle this? ignore, still buffer command, abort?
	if( m_bBufferingActive == true )
		return; // we are already buffering

	m_pBufferedMessage->ResetMessage();
	m_pBufferedMessage->SetConnection( m_pCommandChannel );
	m_pBufferedMessage->SetExceptionMode( IVANetClient::EXC_CLIENT_THROW );
	m_pBufferedMessage->SetMessageType( VA_NP_SPECIAL_BUFFERED_MESSAGE );

	m_bBufferingActive = true;
}

int CVANetNetworkProtocol::ClientEndMessageBuffering()
{
	assert( m_bBufferingActive );

	m_bBufferingActive = false;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
484

Jonas Stienen's avatar
Jonas Stienen committed
485
486
487
488
489
490
491
492
493
494
495
	int iRet = -1;
	try
	{
		m_pBufferedMessage->SetExceptionMode( m_iExceptionHandlingMode );
		m_pBufferedMessage->WriteMessage();

		m_pBufferedMessage->ReadAnswer();
		iRet = m_pBufferedMessage->ReadInt();
	}
	catch( const VistaExceptionBase& oException )
	{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
496
		std::cerr << "VANetNetworkProtocol: caught exception during ClientEndMessageBuffering - "
Jonas Stienen's avatar
Jonas Stienen committed
497
498
499
500
501
502
			<< oException.GetExceptionText() << std::endl;
	}

	return iRet;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
503
int CVANetNetworkProtocol::ClientProcessEventMessageFromServer( VistaConnectionIP* pConnection, std::list<IVAEventHandler*> liCoreEventHandler )
Jonas Stienen's avatar
Jonas Stienen committed
504
505
{
	m_pEventMessage->SetConnection( pConnection );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
506

Jonas Stienen's avatar
Jonas Stienen committed
507
508
509
510
511
512
	try
	{
		m_pEventMessage->ReadMessage();

		switch( m_pEventMessage->GetMessageType() )
		{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
513
514
		case VA_EVENT_CORE_EVENT:
		{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
515
516
			CVAEvent oEvent = m_pEventMessage->ReadEvent();
			for( std::list<IVAEventHandler*>::iterator itHandler = liCoreEventHandler.begin(); itHandler != liCoreEventHandler.end(); ++itHandler )
Jonas Stienen's avatar
Jonas Stienen committed
517
			{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
518
				( *itHandler )->HandleVAEvent( &oEvent );
Jonas Stienen's avatar
Jonas Stienen committed
519
			}
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
520
521
522
523
524
525
526
527
528
529
530
			break;
		}
		case VA_EVENT_NET_EVENT:
		{
			m_pClient->ProcessNetEvent( m_pEventMessage->ReadInt() );
			break;
		}
		default:
		{
			VA_EXCEPT2( PROTOCOL_ERROR, std::string( "Unknown event message type" ) );
		}
Jonas Stienen's avatar
Jonas Stienen committed
531
532
533
534
535
		}
	}
	catch( VistaExceptionBase& oException )
	{
		VA_EXCEPT2( PROTOCOL_ERROR,
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
536
537
538
			std::string( "VANetNetworkProtocol: caught connection exception - " +
			oException.GetExceptionText() ) );
	}
Jonas Stienen's avatar
Jonas Stienen committed
539
540
541
542
543

	return m_pEventMessage->GetMessageType();
}


Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
544
void CVANetNetworkProtocol::ServerPrepareEventMessage( const CVAEvent* pEvent,
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
545
	CVANetMessage* pMessage )
Jonas Stienen's avatar
Jonas Stienen committed
546
547
548
{
	pMessage->ResetMessage();
	pMessage->SetMessageType( VA_EVENT_CORE_EVENT );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
549
	pMessage->WriteEvent( *pEvent );
Jonas Stienen's avatar
Jonas Stienen committed
550
551
552
553
}

void CVANetNetworkProtocol::HandleConnectionClose( VistaConnectionIP* pConnection )
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
554
	if( m_pLastAnswerConnection == pConnection )
Jonas Stienen's avatar
Jonas Stienen committed
555
556
557
558
559
560
561
562
563
		m_pLastAnswerConnection = NULL;
	if( m_pMessage->GetConnection() == pConnection )
		m_pMessage->ClearConnection();
}

CVANetMessage* CVANetNetworkProtocol::ServerGetMessage()
{
	return m_pMessage;
}
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
564
void CVANetNetworkProtocol::ServerSendAnswer( CVANetMessage* )
Jonas Stienen's avatar
Jonas Stienen committed
565
566
567
568
{
	// nothing to do
}

569
CVANetMessage* CVANetNetworkProtocol::ClientInitMessage( int nCommandId, MESSAGE_MODE eMessageMode )
Jonas Stienen's avatar
Jonas Stienen committed
570
571
572
573
574
575
576
577
578
579
580
{
	m_nCurrentMessageMode = eMessageMode;
	if( eMessageMode == MESSAGE_ALLOWS_BUFFERING && m_bBufferingActive )
	{
		m_pBufferedMessage->WriteInt( nCommandId );
		return m_pBufferedMessage;
	}
	else
	{
		m_pMessage->ResetMessage();
		m_pMessage->SetConnection( m_pCommandChannel );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
581
		m_pMessage->SetMessageType( nCommandId );
Jonas Stienen's avatar
Jonas Stienen committed
582
583
584
585
586
		return m_pMessage;
	}
}
void CVANetNetworkProtocol::ClientSendCommand( CVANetMessage* pMessage )
{
587
588
589
590
591

#ifdef VANET_NETWORK_COM_PRINT_DEBUG_INFOS
	std::cout << "[ VANetMessage ][ DEBUG ] Client is trying to send a commad now" << std::endl;
#endif

Jonas Stienen's avatar
Jonas Stienen committed
592
593
	if( pMessage != m_pBufferedMessage )
	{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
594
		int nExceptionMode = -1;
Jonas Stienen's avatar
Jonas Stienen committed
595
596
		switch( m_nCurrentMessageMode )
		{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
597
598
599
600
601
		case MESSAGE_WITH_ANSWER:
		case MESSAGE_ENFORCED_EXCEPTION:
		{
			nExceptionMode = IVANetClient::EXC_CLIENT_THROW;
			break;
Jonas Stienen's avatar
Jonas Stienen committed
602
		}
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
603
604
605
606
607
608
609
610
		case MESSAGE_CONDITIONAL_EXCEPTION:
		case MESSAGE_ALLOWS_BUFFERING:
		{
			nExceptionMode = m_iExceptionHandlingMode;
			break;
		}
		}

Jonas Stienen's avatar
Jonas Stienen committed
611
612
		try
		{
613
614
615
616
617

#ifdef VANET_NETWORK_COM_PRINT_DEBUG_INFOS
			std::cout << "[ VANetMessage ][ DEBUG ] Client is contacting the server" << std::endl;
#endif

Jonas Stienen's avatar
Jonas Stienen committed
618
619
620
			pMessage->SetExceptionMode( nExceptionMode );
			pMessage->WriteMessage();

621
622
623
624
#ifdef VANET_NETWORK_COM_PRINT_DEBUG_INFOS
			std::cout << "[ VANetMessage ][ DEBUG ] Client sent the request and is waiting for a respond" << std::endl;
#endif

Jonas Stienen's avatar
Jonas Stienen committed
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
			if( m_nCurrentMessageMode == MESSAGE_WITH_ANSWER )
			{
				pMessage->ReadAnswer();
				if( pMessage->GetAnswerType() == VA_NP_SPECIAL_EXCEPTION )
				{
					throw( pMessage->ReadException() );
				}
				else
				{
					assert( pMessage->GetAnswerType() == VA_NP_SPECIAL_ANSWER );
				}
			}
			else if( nExceptionMode == IVANetClient::EXC_CLIENT_THROW )
			{
				pMessage->ReadAnswer();
				if( pMessage->GetAnswerType() == VA_NP_SPECIAL_EXCEPTION )
				{
					throw( pMessage->ReadException() );
				}
				else
				{
					assert( pMessage->GetAnswerType() == VA_NP_SPECIAL_NO_EXCEPTION );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
647
				}
Jonas Stienen's avatar
Jonas Stienen committed
648
			}
649
650
651
652
653

#ifdef VANET_NETWORK_COM_PRINT_DEBUG_INFOS
			std::cout << "[ VANetMessage ][ DEBUG ] Client received answer message, no exception on server side detected" << std::endl;
#endif

Jonas Stienen's avatar
Jonas Stienen committed
654
655
656
657
658
659
660
661
		}
		catch( const VistaExceptionBase& )
		{
			//@todo
		}
	}
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
662
void CVANetNetworkProtocol::ClientGetVersionInfo( CVAVersionInfo* pVersionInfo )
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
663
664
{
	if( !pVersionInfo ) return;
665
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_VERSION_INFO, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
666
667
	ClientSendCommand( pMsg );

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
668
	*pVersionInfo = pMsg->ReadVersionInfo();
Jonas Stienen's avatar
Jonas Stienen committed
669
670
671
672
673
674
}

void CVANetNetworkProtocol::ServerGetVersionInfo()
{
	CVANetMessage* pMsg = ServerGetMessage();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
675
	CVAVersionInfo oVersionInfo;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
676
	m_pRealCore->GetVersionInfo( &oVersionInfo );
Jonas Stienen's avatar
Jonas Stienen committed
677

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
678
	pMsg->WriteVersionInfo( oVersionInfo );
Jonas Stienen's avatar
Jonas Stienen committed
679
680
681
682
}

int CVANetNetworkProtocol::ClientGetState()
{
683
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_STATE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
684
685
686
687
688
	ClientSendCommand( pMsg );

	return pMsg->ReadInt();
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
689
void CVANetNetworkProtocol::ServerGetState()
Jonas Stienen's avatar
Jonas Stienen committed
690
691
692
693
694
695
696
697
{
	CVANetMessage* pMsg = ServerGetMessage();
	int iState = m_pRealCore->GetState();
	pMsg->WriteInt( iState );
}

void CVANetNetworkProtocol::ClientInitialize()
{
698
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_INITIALIZE, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
699
700
701
702
703
704
705
706
707
708
	ClientSendCommand( pMsg );
}

void CVANetNetworkProtocol::ServerInitialize()
{
	m_pRealCore->Initialize();
}

void CVANetNetworkProtocol::ClientFinalize()
{
709
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_FINALIZE, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
710
711
712
713
714
715
716
717
718
719
	ClientSendCommand( pMsg );
}

void CVANetNetworkProtocol::ServerFinalize()
{
	m_pRealCore->Finalize();
}

void CVANetNetworkProtocol::ClientReset()
{
720
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_RESET, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
721
722
723
724
725
726
727
728
	ClientSendCommand( pMsg );
}

void CVANetNetworkProtocol::ServerReset()
{
	m_pRealCore->Reset();
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
729
void CVANetNetworkProtocol::ClientAttachEventHandler()
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
730
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
731
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_ATTACH_EVENT_HANDLER, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
732
733
734
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
735
void CVANetNetworkProtocol::ServerAttachEventHandler( VistaConnectionIP* pConn )
Jonas Stienen's avatar
Jonas Stienen committed
736
737
738
739
{
	m_pServer->AttachCoreEventHandler( pConn );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
740
void CVANetNetworkProtocol::ClientDetachEventHandler()
Jonas Stienen's avatar
Jonas Stienen committed
741
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
742
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_DETACH_EVENT_HANDLER, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
743
744
745
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
746
void CVANetNetworkProtocol::ServerDetachEventHandler( VistaConnectionIP* pConn )
Jonas Stienen's avatar
Jonas Stienen committed
747
748
749
750
{
	m_pServer->DetachCoreEventHandler( pConn );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
751
void CVANetNetworkProtocol::ClientGetModules( std::vector<CVAModuleInfo>& m_viModuleInfos )
752
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
753
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_MODULES, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
754
	ClientSendCommand( pMsg );
755
	const int nModules = pMsg->ReadInt();
Jonas Stienen's avatar
Jonas Stienen committed
756
	m_viModuleInfos.clear();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
757
758
759
	m_viModuleInfos.resize( nModules );
	for( int i = 0; i < nModules; i++ )
		pMsg->ReadModuleInfo( m_viModuleInfos[ i ] );
Jonas Stienen's avatar
Jonas Stienen committed
760
761
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
762
void CVANetNetworkProtocol::ServerGetModules()
763
{
Jonas Stienen's avatar
Jonas Stienen committed
764
765
	CVANetMessage* pMsg = ServerGetMessage();
	std::vector<CVAModuleInfo> viModules;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
766
	m_pRealCore->GetModules( viModules );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
767
768
769
	pMsg->WriteInt( ( int ) viModules.size() );
	for( int i = 0; i < ( int ) viModules.size(); i++ )
		pMsg->WriteModuleInfo( viModules[ i ] );
Jonas Stienen's avatar
Jonas Stienen committed
770
771
}

772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
CVAStruct CVANetNetworkProtocol::ClientGetSearchPaths()
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SEARCH_PATHS, MESSAGE_WITH_ANSWER );
	ClientSendCommand( pMsg );
	CVAStruct oPaths;
	pMsg->ReadVAStruct( oPaths );
	return oPaths;
}

void CVANetNetworkProtocol::ServerGetSearchPaths()
{
	CVANetMessage* pMsg = ServerGetMessage();
	const CVAStruct oPaths = m_pRealCore->GetSearchPaths();
	pMsg->WriteVAStruct( oPaths );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
788
789
790
791
792
793
794
795
std::string CVANetNetworkProtocol::ClientFindFilePath( const std::string& sFilePath )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_FIND_FILE_PATH, MESSAGE_WITH_ANSWER );
	pMsg->WriteString( sFilePath );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}

796
void CVANetNetworkProtocol::ServerFindFilePath()
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
797
798
799
800
801
802
803
{
	CVANetMessage* pMsg = ServerGetMessage();
	const std::string sFilePath = pMsg->ReadString();
	const std::string sFoundFilePath = m_pRealCore->FindFilePath( sFilePath );
	pMsg->WriteString( sFoundFilePath );
}

804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
CVAStruct CVANetNetworkProtocol::ClientGetCoreConfiguration( const bool bFilterEnabled )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_CORE_CONFIGURATION, MESSAGE_WITH_ANSWER );
	pMsg->WriteBool( bFilterEnabled );
	ClientSendCommand( pMsg );
	CVAStruct oCoreConfig;
	pMsg->ReadVAStruct( oCoreConfig );
	return oCoreConfig;
}

void CVANetNetworkProtocol::ServerGetCoreConfiguration()
{
	CVANetMessage* pMsg = ServerGetMessage();
	const bool bFilterEnabled = pMsg->ReadBool();
	const CVAStruct oCoreConfig = m_pRealCore->GetCoreConfiguration( bFilterEnabled );
	pMsg->WriteVAStruct( oCoreConfig );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
822
CVAStruct CVANetNetworkProtocol::ClientGetHardwareConfiguration()
823
824
825
826
827
828
829
830
831
832
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_HARDWARE_CONFIGURATION, MESSAGE_WITH_ANSWER );
	ClientSendCommand( pMsg );
	CVAStruct oHWConfig;
	pMsg->ReadVAStruct( oHWConfig );
	return oHWConfig;
}
void CVANetNetworkProtocol::ServerGetHardwareConfiguration()
{
	CVANetMessage* pMsg = ServerGetMessage();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
833
	const CVAStruct oHWConfig = m_pRealCore->GetHardwareConfiguration();
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
	pMsg->WriteVAStruct( oHWConfig );
}

CVAStruct CVANetNetworkProtocol::ClientGetFileList( const bool bRecursive, const std::string& sSuffixFilter )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_FILE_LIST, MESSAGE_WITH_ANSWER );
	pMsg->WriteBool( bRecursive );
	pMsg->WriteString( sSuffixFilter );
	ClientSendCommand( pMsg );
	CVAStruct oFileList;
	pMsg->ReadVAStruct( oFileList );
	return oFileList;
}

void CVANetNetworkProtocol::ServerGetFileList()
{
	CVANetMessage* pMsg = ServerGetMessage();
	const bool bRecursive = pMsg->ReadBool();
	const std::string sFileSuffixMask = pMsg->ReadString();
	const CVAStruct oFileList = m_pRealCore->GetFileList( bRecursive, sFileSuffixMask );
	pMsg->WriteVAStruct( oFileList );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
857
CVAStruct CVANetNetworkProtocol::ClientCallModule( const std::string& sModuleName, const CVAStruct& oArgs )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
858
859
860
861
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CALL_MODULE, MESSAGE_WITH_ANSWER );
	pMsg->WriteString( sModuleName );
	pMsg->WriteVAStruct( oArgs );
Jonas Stienen's avatar
Jonas Stienen committed
862
	ClientSendCommand( pMsg );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
863
	CVAStruct oReturn;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
864
	pMsg->ReadVAStruct( oReturn );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
865
	return oReturn;
Jonas Stienen's avatar
Jonas Stienen committed
866
867
868
869
870
871
}

void CVANetNetworkProtocol::ServerCallModule()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sModuleName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
872
	CVAStruct oArgs;
Jonas Stienen's avatar
Jonas Stienen committed
873
	pMsg->ReadVAStruct( oArgs );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
874
	CVAStruct oReturn = m_pRealCore->CallModule( sModuleName, oArgs );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
875
	pMsg->WriteVAStruct( oReturn );
Jonas Stienen's avatar
Jonas Stienen committed
876
877
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
878
int CVANetNetworkProtocol::ClientCreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName )
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
879
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
880
881
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_DIRECTIVITY, MESSAGE_WITH_ANSWER );
	pMsg->WriteVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
882
883
884
885
886
887
888
	pMsg->WriteString( sName );

	ClientSendCommand( pMsg );

	return pMsg->ReadInt();
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
889
void CVANetNetworkProtocol::ServerCreateDirectivityFromParameters()
Jonas Stienen's avatar
Jonas Stienen committed
890
891
892
{
	CVANetMessage* pMsg = ServerGetMessage();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
893
894
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
895
896
	std::string sName = pMsg->ReadString();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
897
	const int iDirID = m_pRealCore->CreateDirectivityFromParameters( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
898
899
900
901

	pMsg->WriteInt( iDirID );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
902
bool CVANetNetworkProtocol::ClientDeleteDirectivity( const int iDirID )
Jonas Stienen's avatar
Jonas Stienen committed
903
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
904
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_DELETE_DIRECTIVITY, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
905
906
907
908
909
910
911
	pMsg->WriteInt( iDirID );

	ClientSendCommand( pMsg );

	return pMsg->ReadBool();
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
912
void CVANetNetworkProtocol::ServerDeleteDirectivity()
Jonas Stienen's avatar
Jonas Stienen committed
913
914
915
{
	CVANetMessage* pMsg = ServerGetMessage();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
916
	const int iDirID = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
917

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
918
	const bool bRes = m_pRealCore->DeleteDirectivity( iDirID );
Jonas Stienen's avatar
Jonas Stienen committed
919
920
921
	pMsg->WriteBool( bRes );
}

922
CVADirectivityInfo CVANetNetworkProtocol::ClientGetDirectivityInfo( const int iDirID )
Jonas Stienen's avatar
Jonas Stienen committed
923
{
924
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_DIRECTIVITY_INFO, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
925
926
927
928
929
930
931
932
933
934
935
936
937
	pMsg->WriteInt( iDirID );

	ClientSendCommand( pMsg );

	CVADirectivityInfo oDirInfo = pMsg->ReadDirectivityInfo();
	return oDirInfo;
}

void CVANetNetworkProtocol::ServerGetDirectivityInfo()
{
	CVANetMessage* pMsg = ServerGetMessage();

	int iDirID = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
938
939

	CVADirectivityInfo oDirInfo = m_pRealCore->GetDirectivityInfo( iDirID );
Jonas Stienen's avatar
Jonas Stienen committed
940
941
942
943

	pMsg->WriteDirectivityInfo( oDirInfo );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
944
void CVANetNetworkProtocol::ClientGetDirectivityInfos( std::vector<CVADirectivityInfo>& vdiDest )
Jonas Stienen's avatar
Jonas Stienen committed
945
{
946
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_DIRECTIVITY_INFOS, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
947
948
	ClientSendCommand( pMsg );
	vdiDest.clear();
949
	const int iNumDirectivities = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
950
	for( int i = 0; i < iNumDirectivities; i++ )
Jonas Stienen's avatar
Jonas Stienen committed
951
952
953
954
955
956
957
		vdiDest.push_back( pMsg->ReadDirectivityInfo() );
}

void CVANetNetworkProtocol::ServerGetDirectivityInfos()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::vector<CVADirectivityInfo> vInfos;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
958
959
960
961
	m_pRealCore->GetDirectivityInfos( vInfos );
	pMsg->WriteInt( ( int ) vInfos.size() );
	for( size_t i = 0; i < vInfos.size(); i++ )
		pMsg->WriteDirectivityInfo( vInfos[ i ] );
Jonas Stienen's avatar
Jonas Stienen committed
962
963
}

964
void CVANetNetworkProtocol::ClientSetDirectivityName( const int iID, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
965
{
966
967
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_DIRECTIVITY_NAME, MESSAGE_ALLOWS_BUFFERING );
	pMsg->WriteInt( iID );
Jonas Stienen's avatar
Jonas Stienen committed
968
	pMsg->WriteString( sName );
969
970
971
972
973
974
975
976
977
978
	ClientSendCommand( pMsg );
}

void CVANetNetworkProtocol::ServerSetDirectivityName()
{
	CVANetMessage* pMsg = ServerGetMessage();
	const int iID = pMsg->ReadInt();
	const std::string sName = pMsg->ReadString();
	m_pRealCore->SetDirectivityName( iID, sName );
}
Jonas Stienen's avatar
Jonas Stienen committed
979

980
981
982
983
std::string CVANetNetworkProtocol::ClientGetDirectivityName( const int iID )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_DIRECTIVITY_NAME, MESSAGE_WITH_ANSWER );
	pMsg->WriteInt( iID );
Jonas Stienen's avatar
Jonas Stienen committed
984
	ClientSendCommand( pMsg );
985
986
987
	const std::string sName = pMsg->ReadString();
	return sName;
}
Jonas Stienen's avatar
Jonas Stienen committed
988

989
990
991
992
993
994
void CVANetNetworkProtocol::ServerGetDirectivityName()
{
	CVANetMessage* pMsg = ServerGetMessage();
	const int iID = pMsg->ReadInt();
	const std::string sName = m_pRealCore->GetDirectivityName( iID );
	pMsg->WriteString( sName );
Jonas Stienen's avatar
Jonas Stienen committed
995
996
}

997
998
999
1000
1001
1002
1003
1004
1005
void CVANetNetworkProtocol::ClientSetDirectivityParameters( const int iID, const CVAStruct& oParams )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_DIRECTIVITY_PARAMETERS, MESSAGE_ALLOWS_BUFFERING );
	pMsg->WriteInt( iID );
	pMsg->WriteVAStruct( oParams );
	ClientSendCommand( pMsg );
}

void CVANetNetworkProtocol::ServerSetDirectivityParameters()
Jonas Stienen's avatar
Jonas Stienen committed
1006
1007
{
	CVANetMessage* pMsg = ServerGetMessage();
1008
1009
1010
1011
	const int iID = pMsg->ReadInt();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
	m_pRealCore->SetDirectivityParameters( iID, oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1012

1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
}

CVAStruct CVANetNetworkProtocol::ClientGetDirectivityParameters( const int iID, const CVAStruct& oParams )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_DIRECTIVITY_PARAMETERS, MESSAGE_WITH_ANSWER );
	pMsg->WriteInt( iID );
	pMsg->WriteVAStruct( oParams );
	ClientSendCommand( pMsg );
	CVAStruct oReturn;
	pMsg->ReadVAStruct( oReturn );
	return oReturn;
}

void CVANetNetworkProtocol::ServerGetDirectivityParameters()
{
	CVANetMessage* pMsg = ServerGetMessage();
	const int iID = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1030
1031
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
1032
1033
1034
	const CVAStruct oReturn = m_pRealCore->GetDirectivityParameters( iID, oParams );
	pMsg->WriteVAStruct( oReturn );
}
Jonas Stienen's avatar
Jonas Stienen committed
1035

1036
1037
1038
1039
1040
1041
1042
1043
std::string CVANetNetworkProtocol::ClientCreateSignalSourceBufferFromParameters( const CVAStruct& oParams, const std::string& sName )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_BUFFER_FROM_PARAMETERS, MESSAGE_WITH_ANSWER );
	pMsg->WriteVAStruct( oParams );
	pMsg->WriteString( sName );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}
Jonas Stienen's avatar
Jonas Stienen committed
1044

1045
1046
1047
1048
1049
1050
1051
void CVANetNetworkProtocol::ServerCreateSignalSourceBufferFromParameters()
{
	CVANetMessage* pMsg = ServerGetMessage();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
	const std::string sName = pMsg->ReadString();
	const std::string sID = m_pRealCore->CreateSignalSourceBufferFromParameters( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1052
1053
1054
	pMsg->WriteString( sID );
}

1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
std::string CVANetNetworkProtocol::ClientCreateSignalSourcePrototypeFromParameters( const CVAStruct& oParams, const std::string& sName )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_PROTOTYPE_FROM_PARAMETERS, MESSAGE_WITH_ANSWER );
	pMsg->WriteVAStruct( oParams );
	pMsg->WriteString( sName );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}

void CVANetNetworkProtocol::ServerCreateSignalSourcePrototypeFromParameters()
{
	CVANetMessage* pMsg = ServerGetMessage();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
	const std::string sName = pMsg->ReadString();
	const std::string sID = m_pRealCore->CreateSignalSourcePrototypeFromParameters( oParams, sName );
	pMsg->WriteString( sID );
}

1074
1075
std::string CVANetNetworkProtocol::ClientCreateTextToSpeechSignalSource( const std::string& sName )
{
1076
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_TEXT_TO_SPEECH, MESSAGE_WITH_ANSWER );
1077
1078
1079
1080
1081
1082
1083
1084
1085
	pMsg->WriteString( sName );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}

void CVANetNetworkProtocol::ServerCreateTextToSpeechSignalSource()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1086
	std::string sID = m_pRealCore->CreateSignalSourceTextToSpeech( sName );
1087
1088
1089
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1090
std::string CVANetNetworkProtocol::ClientCreateSequencerSignalSource( const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1091
{
1092
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_SEQUENCER, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1093
1094
1095
1096
1097
1098
1099
1100
1101
	pMsg->WriteString( sName );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}

void CVANetNetworkProtocol::ServerCreateSequencerSignalSource()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1102
	std::string sID = m_pRealCore->CreateSignalSourceSequencer( sName );
Jonas Stienen's avatar
Jonas Stienen committed
1103
1104
1105
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1106
std::string CVANetNetworkProtocol::ClientCreateNetworkStreamSignalSource( const std::string& sInterface, const int iPort, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1107
{
1108
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_NETWORK_STREAM, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126

	pMsg->WriteString( sInterface );
	pMsg->WriteInt( iPort );
	pMsg->WriteString( sName );

	ClientSendCommand( pMsg );

	return pMsg->ReadString();
}

void CVANetNetworkProtocol::ServerCreateNetworkStreamSignalSource()
{
	CVANetMessage* pMsg = ServerGetMessage();

	std::string sInterface = pMsg->ReadString();
	int iPort = pMsg->ReadInt();
	std::string sName = pMsg->ReadString();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1127
	std::string iID = m_pRealCore->CreateSignalSourceNetworkStream( sInterface, iPort, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1128

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1129
	pMsg->WriteString( iID );
Jonas Stienen's avatar
Jonas Stienen committed
1130
1131
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1132
std::string CVANetNetworkProtocol::ClientCreateEngineSignalSource( const CVAStruct& oParams, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1133
{
1134
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_ENGINE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1135

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1136
	pMsg->WriteVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
	pMsg->WriteString( sName );

	ClientSendCommand( pMsg );

	return pMsg->ReadString();
}

void CVANetNetworkProtocol::ServerCreateEngineSignalSource()
{
	CVANetMessage* pMsg = ServerGetMessage();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1147
1148
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1149
	std::string sName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1150
	std::string sID = m_pRealCore->CreateSignalSourceEngine( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1151
1152
1153
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1154
std::string CVANetNetworkProtocol::ClientCreateSignalSourceMachine( const CVAStruct& oParams, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1155
{
1156
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_MACHINE, MESSAGE_WITH_ANSWER );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1157
1158
1159
1160
1161
	pMsg->WriteVAStruct( oParams );
	pMsg->WriteString( sName );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}
Jonas Stienen's avatar
Jonas Stienen committed
1162

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1163
1164
1165
1166
1167
void CVANetNetworkProtocol::ServerCreateSignalSourceMachine()
{
	CVANetMessage* pMsg = ServerGetMessage();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1168
	std::string sName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1169
	std::string sID = m_pRealCore->CreateSignalSourceMachine( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1170
1171
1172
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1173
bool CVANetNetworkProtocol::ClientDeleteSignalSource( const std::string& sID )
Jonas Stienen's avatar
Jonas Stienen committed
1174
{
1175
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_DELETE_SIGNALSOURCE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
	pMsg->WriteString( sID );
	ClientSendCommand( pMsg );
	return pMsg->ReadBool();
}

void CVANetNetworkProtocol::ServerDeleteSignalSource()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sID = pMsg->ReadString();
	bool bResult = m_pRealCore->DeleteSignalSource( sID );
	pMsg->WriteBool( bResult );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1189
std::string CVANetNetworkProtocol::ClientGetSoundSourceSignalSource( const int iSoundSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1190
{
1191
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SOUND_SOURCE_SIGNALSOURCE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1192
1193
1194
1195
1196
1197
1198
1199
	pMsg->WriteInt( iSoundSourceID );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}

void CVANetNetworkProtocol::ServerGetSoundSourceSignalSource()
{
	CVANetMessage* pMsg = ServerGetMessage();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1200
	const int iID = pMsg->ReadInt();
Jonas Stienen's avatar
Jonas Stienen committed
1201
1202
1203
1204
	std::string sSignalSourceID = m_pRealCore->GetSoundSourceSignalSource( iID );
	pMsg->WriteString( sSignalSourceID );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1205
CVASignalSourceInfo CVANetNetworkProtocol::ClientGetSignalSourceInfo( const std::string& sSignalSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1206
{
1207
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNALSOURCE_INFO, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
	pMsg->WriteString( sSignalSourceID );
	ClientSendCommand( pMsg );
	CVASignalSourceInfo oSignalSourceInfo = pMsg->ReadSignalSourceInfo();
	return oSignalSourceInfo;
}

void CVANetNetworkProtocol::ServerGetSignalSourceInfo()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1218
	CVASignalSourceInfo oSignalSourceInfo = m_pRealCore->GetSignalSourceInfo( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
1219
1220
1221
	pMsg->WriteSignalSourceInfo( oSignalSourceInfo );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1222
void CVANetNetworkProtocol::ClientGetSignalSourceInfos( std::vector<CVASignalSourceInfo>& vssiDest )
Jonas Stienen's avatar
Jonas Stienen committed
1223
{
1224
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNALSOURCE_INFOS, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1225
1226
1227
	ClientSendCommand( pMsg );
	vssiDest.clear();
	int iNumSignalSources = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1228
	for( int i = 0; i < iNumSignalSources; i++ )
Jonas Stienen's avatar
Jonas Stienen committed
1229
1230
1231
1232
1233
1234
1235
		vssiDest.push_back( pMsg->ReadSignalSourceInfo() );
}

void CVANetNetworkProtocol::ServerGetSignalSourceInfos()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::vector<CVASignalSourceInfo> vInfos;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1236
1237
1238
1239
	m_pRealCore->GetSignalSourceInfos( vInfos );
	pMsg->WriteInt( ( int ) vInfos.size() );
	for( size_t i = 0; i < vInfos.size(); i++ )
		pMsg->WriteSignalSourceInfo( vInfos[ i ] );
Jonas Stienen's avatar
Jonas Stienen committed
1240
1241
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1242
int CVANetNetworkProtocol::ClientGetSignalSourceBufferPlaybackState( const std::string& sSignalSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1243
{
1244
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNAL_SOURCE_BUFFER_PLAYBACK_STATE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1245
1246
	pMsg->WriteString( sSignalSourceID );
	ClientSendCommand( pMsg );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1247
	const int iPlayState = pMsg->ReadInt();
Jonas Stienen's avatar
Jonas Stienen committed
1248
1249
1250
	return iPlayState;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1251
void CVANetNetworkProtocol::ServerGetSignalSourceBufferPlaybackState()
Jonas Stienen's avatar
Jonas Stienen committed
1252
1253
1254
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1255
	const int iPlayState = m_pRealCore->GetSignalSourceBufferPlaybackState( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
1256
1257
1258
	pMsg->WriteInt( iPlayState );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1259
void CVANetNetworkProtocol::ClientSetSignalSourceBufferPlaybackAction( const std::string& sSignalSourceID, const int iPlayAction )
Jonas Stienen's avatar
Jonas Stienen committed
1260
{
1261
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNAL_SOURCE_BUFFER_PLAYBACK_ACTION, MESSAGE_ALLOWS_BUFFERING );
Jonas Stienen's avatar
Jonas Stienen committed
1262
1263
1264
1265
1266
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteInt( iPlayAction );
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1267
void CVANetNetworkProtocol::ServerSetSignalSourceBufferPlaybackAction()
Jonas Stienen's avatar
Jonas Stienen committed
1268
1269
1270
1271
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
	int iPlayAction = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1272
	m_pRealCore->SetSignalSourceBufferPlaybackAction( sSignalSourceID, iPlayAction );
Jonas Stienen's avatar
Jonas Stienen committed
1273
1274
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1275
void CVANetNetworkProtocol::ClientSetSignalSourceBufferLooping( const std::string& sSignalSourceID, const bool bLooping )
Jonas Stienen's avatar
Jonas Stienen committed
1276
{
1277
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNAL_SOURCE_BUFFER_LOOPING, MESSAGE_ALLOWS_BUFFERING );
Jonas Stienen's avatar
Jonas Stienen committed
1278
1279
1280
1281
1282
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteBool( bLooping );
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1283
void CVANetNetworkProtocol::ServerSetSignalSourceBufferLooping()
Jonas Stienen's avatar
Jonas Stienen committed
1284
1285
1286
1287
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
	bool bLooping = pMsg->ReadBool();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1288
	m_pRealCore->SetSignalSourceBufferLooping( sSignalSourceID, bLooping );
Jonas Stienen's avatar
Jonas Stienen committed
1289
1290
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1291
bool CVANetNetworkProtocol::ClientGetSignalSourceBufferLooping( const std::string& sSignalSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1292
{
1293
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNAL_SOURCE_BUFFER_LOOPING, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1294
1295
1296
1297
1298
1299
	pMsg->WriteString( sSignalSourceID );
	ClientSendCommand( pMsg );
	bool bLooping = pMsg->ReadBool();
	return bLooping;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1300
void CVANetNetworkProtocol::ServerGetSignalSourceBufferLooping()
Jonas Stienen's avatar
Jonas Stienen committed
1301
1302
1303
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1304
	bool bLooping = m_pRealCore->GetSignalSourceBufferLooping( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
1305
1306
1307
	pMsg->WriteBool( bLooping );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1308
void CVANetNetworkProtocol::ClientSetSignalSourceBufferPlaybackPosition( const std::string& sSignalSourceID, const double dPlaybackPosition )
Jonas Stienen's avatar
Jonas Stienen committed
1309
{
1310
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNAL_SOURCE_BUFFER_PLAYBACK_POSITION, MESSAGE_ALLOWS_BUFFERING );
Jonas Stienen's avatar
Jonas Stienen committed
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteDouble( dPlaybackPosition );
	ClientSendCommand( pMsg );
}

void CVANetNetworkProtocol::ServerSetAudiofileSignalSourcePlaybackPosition()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
	double dPlaybackPosition = pMsg->ReadDouble();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1321
	m_pRealCore->SetSignalSourceBufferPlaybackPosition( sSignalSourceID, dPlaybackPosition );
Jonas Stienen's avatar
Jonas Stienen committed
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
}

void CVANetNetworkProtocol::ClientSetSignalSourceParameters( const std::string& sSignalSourceID, const CVAStruct& oParams )
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNALSOURCE_PARAMETERS, MESSAGE_ALLOWS_BUFFERING );
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteVAStruct( oParams );
	ClientSendCommand( pMsg );
	return;
}

void CVANetNetworkProtocol::ServerSetSignalSourceParameters()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sID = pMsg->ReadString();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
	m_pRealCore->SetSignalSourceParameters( sID, oParams );
	return;
}

CVAStruct CVANetNetworkProtocol::ClientGetSignalSourceParameters( const std::string& sSignalSourceID, const CVAStruct& oParams )
{
1345
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNAL_SOURCE_PARAMETERS, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteVAStruct( oParams );
	ClientSendCommand( pMsg );
	CVAStruct oRet;
	pMsg->ReadVAStruct( oRet );
	return oRet;
}

void CVANetNetworkProtocol::ServerGetSignalSourceParameters()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sID = pMsg->ReadString();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
	CVAStruct oRet = m_pRealCore->GetSignalSourceParameters( sID, oParams );
	pMsg->WriteVAStruct( oRet );
	return;
}

</