VANetNetworkProtocol.cpp 138 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
 *  --------------------------------------------------------------------------------------------
 *
 *    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
 *
 *  --------------------------------------------------------------------------------------------
 */

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() );
Jonas Stienen's avatar
Jonas Stienen committed
150
151
152
		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() );
153
154
155
156
157
		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() );
158
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SIGNAL_SOURCE_PARAMETERS, ServerGetSignalSourceParameters() );
Jonas Stienen's avatar
Jonas Stienen committed
159
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SIGNALSOURCE_PARAMETERS, ServerSetSignalSourceParameters() );
160
161
162
		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
163
164

		// Synchronization functions
165
166
167
		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
168

Jonas Stienen's avatar
Jonas Stienen committed
169
170
		// Sound sources
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_IDS, ServerGetSoundSourceIDs() );
171
172
173
174
175
176
177
		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() );
178
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_SIGNALSOURCE, ServerSetSoundSourceSignalSource() );
179
180
181
182
183
184
185
186
187
188
189
		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
190
191
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_POSE, ServerSetSoundSourcePose() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_POSE, ServerGetSoundSourcePose() );
192
193
194
		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() );
195
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_ORIENTATION, ServerGetSoundSourceOrientation() );
196
197
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_SOURCE_ORIENTATION_VU, ServerSetSoundSourceOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_SOURCE_ORIENTATION_VU, ServerGetSoundSourceOrientationVU() );
198
199
200
		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
201

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
202
		// SoundReceivers
203
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_IDS, ServerGetSoundReceiverIDs() );
204
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_INFO, ServerGetSoundReceiverInfo() );
205
206
207
208
209
210
211
212
213
214
215
216
217
		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() );
218
219
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_POSE, ServerSetSoundReceiverPose() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_POSE, ServerGetSoundReceiverPose() );
220
221
222
223
224
225
		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() );
226
227
228
229
230
231
232
233
		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() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_REAL_WORLD_POSITION_ORIENTATION_VU, ServerSetSoundReceiverRealWorldPositionOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_REAL_WORLD_POSITION_ORIENTATION_VU, ServerGetSoundReceiverRealWorldPositionOrientationVU() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_GEOMETRY_MESH, ServerSetSoundReceiverGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_GEOMETRY_MESH, ServerGetSoundReceiverGeometryMesh() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_REAL_WORLD_POSE, ServerSetSoundReceiverRealWorldPose() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_REAL_WORLD_POSE, ServerGetSoundReceiverRealWorldPose() );
234
235
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_RECEIVER_REAL_WORLD_TORSO_ORIENTATION, ServerSetSoundReceiverRealWorldTorsoOrientation() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_RECEIVER_REAL_WORLD_TORSO_ORIENTATION, ServerGetSoundReceiverRealWorldTorsoOrientation() );
Jonas Stienen's avatar
Jonas Stienen committed
236
237

		// Scene
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
238
239
		SERVER_FUNCTION_MAPPING( VA_NP_SCENE_CREATE, ServerCreateScene() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SCENE_IDS, ServerGetSceneIDs() );
Jonas Stienen's avatar
Jonas Stienen committed
240
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SCENE_INFO, ServerGetSceneInfo() );
241
242
243
244
		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
245

246
		SERVER_FUNCTION_MAPPING( VA_NP_CREATE_SOUND_PORTAL, ServerCreateSoundPortal() );
247
248
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_NAME, ServerGetSoundPortalName() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_NAME, ServerSetSoundPortalName() );
249
250
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_IDS, ServerGetSoundPortalIDs() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_INFO, ServerGetSoundPortalInfo() );
251
252
		SERVER_FUNCTION_MAPPING( VA_NP_GET_SOUND_PORTAL_PARAMETERS, ServerGetSoundPortalParameters() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_SOUND_PORTAL_PARAMETERS, ServerSetSoundPortalParameters() );
253
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
		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
291

292
293
294
295
296
297
298
299
300
301
302
303
304
305
		// 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
306
307
308
		// Global functions
		SERVER_FUNCTION_MAPPING( VA_NP_GET_INPUT_GAIN, ServerGetInputGain() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_INPUT_GAIN, ServerSetInputGain() );
309
		SERVER_FUNCTION_MAPPING( VA_NP_GET_INPUT_MUTED, ServerGetInputMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
310
311
312
		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() );
313
		SERVER_FUNCTION_MAPPING( VA_NP_GET_OUTPUT_MUTED, ServerGetOutputMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
314
315
316
		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() );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
317
318
319
320
		SERVER_FUNCTION_MAPPING( VA_NP_GET_ACTIVE_SOUND_RECEIVER, ServerGetActiveSoundReceiver() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_ACTIVE_SOUND_RECEIVER, ServerSetActiveSoundReceiver() );
		SERVER_FUNCTION_MAPPING( VA_NP_GET_ACTIVE_SOUND_RECEIVER_EXPLICIT_RENDERER, ServerGetActiveSoundReceiverExplicitRenderer() );
		SERVER_FUNCTION_MAPPING( VA_NP_SET_ACTIVE_SOUND_RECEIVER_EXPLICIT_RENDERER, ServerSetActiveSoundReceiverExplicitRenderer() );
Jonas Stienen's avatar
Jonas Stienen committed
321
322
323
324
325
326
327
		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() );
328
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_GET_MUTED, ServerGetRenderingModuleMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
329
		SERVER_FUNCTION_MAPPING( VA_NP_RENDERER_SET_MUTED, ServerSetRenderingModuleMuted() );
330
331
332
333
		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
334
335
336
337

		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() );
338
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_GET_MUTED, ServerGetReproductionModuleMuted() );
Jonas Stienen's avatar
Jonas Stienen committed
339
		SERVER_FUNCTION_MAPPING( VA_NP_REPRODUCTION_SET_MUTED, ServerSetReproductionModuleMuted() );
340
341
		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
342

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
343
344
345
346
347
348
349
350
	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
351
352
	}
}
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
353

Jonas Stienen's avatar
Jonas Stienen committed
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
bool CVANetNetworkProtocol::ProcessMessageFromClient( VistaConnectionIP* pConnection )
{
	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
372
	}
Jonas Stienen's avatar
Jonas Stienen committed
373
374
	catch( VistaExceptionBase& oException )
	{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
375
		std::cerr << "VANetNetworkProtocol: caught connection exception - "
Jonas Stienen's avatar
Jonas Stienen committed
376
377
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
			<< 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
417
418
419
420
421
422
423
424
425
426
427
428
429
		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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
		}
	}

	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();
	}

	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
459
		return;
Jonas Stienen's avatar
Jonas Stienen committed
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

	// @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
478

Jonas Stienen's avatar
Jonas Stienen committed
479
480
481
482
483
484
485
486
487
488
489
	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
490
		std::cerr << "VANetNetworkProtocol: caught exception during ClientEndMessageBuffering - "
Jonas Stienen's avatar
Jonas Stienen committed
491
492
493
494
495
496
			<< oException.GetExceptionText() << std::endl;
	}

	return iRet;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
497
int CVANetNetworkProtocol::ClientProcessEventMessageFromServer( VistaConnectionIP* pConnection, std::list<IVAEventHandler*> liCoreEventHandler )
Jonas Stienen's avatar
Jonas Stienen committed
498
499
{
	m_pEventMessage->SetConnection( pConnection );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
500

Jonas Stienen's avatar
Jonas Stienen committed
501
502
503
504
505
506
	try
	{
		m_pEventMessage->ReadMessage();

		switch( m_pEventMessage->GetMessageType() )
		{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
507
508
		case VA_EVENT_CORE_EVENT:
		{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
509
510
			CVAEvent oEvent = m_pEventMessage->ReadEvent();
			for( std::list<IVAEventHandler*>::iterator itHandler = liCoreEventHandler.begin(); itHandler != liCoreEventHandler.end(); ++itHandler )
Jonas Stienen's avatar
Jonas Stienen committed
511
			{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
512
				( *itHandler )->HandleVAEvent( &oEvent );
Jonas Stienen's avatar
Jonas Stienen committed
513
			}
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
514
515
516
517
518
519
520
521
522
523
524
			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
525
526
527
528
529
		}
	}
	catch( VistaExceptionBase& oException )
	{
		VA_EXCEPT2( PROTOCOL_ERROR,
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
530
531
532
			std::string( "VANetNetworkProtocol: caught connection exception - " +
			oException.GetExceptionText() ) );
	}
Jonas Stienen's avatar
Jonas Stienen committed
533
534
535
536
537

	return m_pEventMessage->GetMessageType();
}


Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
538
void CVANetNetworkProtocol::ServerPrepareEventMessage( const CVAEvent* pEvent,
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
539
	CVANetMessage* pMessage )
Jonas Stienen's avatar
Jonas Stienen committed
540
541
542
{
	pMessage->ResetMessage();
	pMessage->SetMessageType( VA_EVENT_CORE_EVENT );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
543
	pMessage->WriteEvent( *pEvent );
Jonas Stienen's avatar
Jonas Stienen committed
544
545
546
547
}

void CVANetNetworkProtocol::HandleConnectionClose( VistaConnectionIP* pConnection )
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
548
	if( m_pLastAnswerConnection == pConnection )
Jonas Stienen's avatar
Jonas Stienen committed
549
550
551
552
553
554
555
556
557
		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
558
void CVANetNetworkProtocol::ServerSendAnswer( CVANetMessage* )
Jonas Stienen's avatar
Jonas Stienen committed
559
560
561
562
{
	// nothing to do
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
563
564
CVANetMessage* CVANetNetworkProtocol::ClientInitMessage( int nCommandId,
	MESSAGE_MODE eMessageMode )
Jonas Stienen's avatar
Jonas Stienen committed
565
566
567
568
569
570
571
572
573
574
575
{
	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
576
		m_pMessage->SetMessageType( nCommandId );
Jonas Stienen's avatar
Jonas Stienen committed
577
578
579
580
581
582
583
		return m_pMessage;
	}
}
void CVANetNetworkProtocol::ClientSendCommand( CVANetMessage* pMessage )
{
	if( pMessage != m_pBufferedMessage )
	{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
584
		int nExceptionMode = -1;
Jonas Stienen's avatar
Jonas Stienen committed
585
586
		switch( m_nCurrentMessageMode )
		{
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
587
588
589
590
591
		case MESSAGE_WITH_ANSWER:
		case MESSAGE_ENFORCED_EXCEPTION:
		{
			nExceptionMode = IVANetClient::EXC_CLIENT_THROW;
			break;
Jonas Stienen's avatar
Jonas Stienen committed
592
		}
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
593
594
595
596
597
598
599
600
		case MESSAGE_CONDITIONAL_EXCEPTION:
		case MESSAGE_ALLOWS_BUFFERING:
		{
			nExceptionMode = m_iExceptionHandlingMode;
			break;
		}
		}

Jonas Stienen's avatar
Jonas Stienen committed
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
		try
		{
			pMessage->SetExceptionMode( nExceptionMode );
			pMessage->WriteMessage();

			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
628
				}
Jonas Stienen's avatar
Jonas Stienen committed
629
630
631
632
633
634
635
636
637
			}
		}
		catch( const VistaExceptionBase& )
		{
			//@todo
		}
	}
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
638
void CVANetNetworkProtocol::ClientGetVersionInfo( CVAVersionInfo* pVersionInfo )
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
639
640
{
	if( !pVersionInfo ) return;
641
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_VERSION_INFO, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
642
643
	ClientSendCommand( pMsg );

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
644
	*pVersionInfo = pMsg->ReadVersionInfo();
Jonas Stienen's avatar
Jonas Stienen committed
645
646
647
648
649
650
}

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

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
651
	CVAVersionInfo oVersionInfo;
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
652
	m_pRealCore->GetVersionInfo( &oVersionInfo );
Jonas Stienen's avatar
Jonas Stienen committed
653

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
654
	pMsg->WriteVersionInfo( oVersionInfo );
Jonas Stienen's avatar
Jonas Stienen committed
655
656
657
658
}

int CVANetNetworkProtocol::ClientGetState()
{
659
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_STATE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
660
661
662
663
664
	ClientSendCommand( pMsg );

	return pMsg->ReadInt();
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
665
void CVANetNetworkProtocol::ServerGetState()
Jonas Stienen's avatar
Jonas Stienen committed
666
667
668
669
670
671
672
673
{
	CVANetMessage* pMsg = ServerGetMessage();
	int iState = m_pRealCore->GetState();
	pMsg->WriteInt( iState );
}

void CVANetNetworkProtocol::ClientInitialize()
{
674
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_INITIALIZE, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
675
676
677
678
679
680
681
682
683
684
	ClientSendCommand( pMsg );
}

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

void CVANetNetworkProtocol::ClientFinalize()
{
685
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_FINALIZE, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
686
687
688
689
690
691
692
693
694
695
	ClientSendCommand( pMsg );
}

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

void CVANetNetworkProtocol::ClientReset()
{
696
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_RESET, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
697
698
699
700
701
702
703
704
	ClientSendCommand( pMsg );
}

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

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
705
void CVANetNetworkProtocol::ClientAttachEventHandler()
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
706
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
707
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_ATTACH_EVENT_HANDLER, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
708
709
710
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
711
void CVANetNetworkProtocol::ServerAttachEventHandler( VistaConnectionIP* pConn )
Jonas Stienen's avatar
Jonas Stienen committed
712
713
714
715
{
	m_pServer->AttachCoreEventHandler( pConn );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
716
void CVANetNetworkProtocol::ClientDetachEventHandler()
Jonas Stienen's avatar
Jonas Stienen committed
717
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
718
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_DETACH_EVENT_HANDLER, MESSAGE_ENFORCED_EXCEPTION );
Jonas Stienen's avatar
Jonas Stienen committed
719
720
721
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
722
void CVANetNetworkProtocol::ServerDetachEventHandler( VistaConnectionIP* pConn )
Jonas Stienen's avatar
Jonas Stienen committed
723
724
725
726
{
	m_pServer->DetachCoreEventHandler( pConn );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
727
void CVANetNetworkProtocol::ClientGetModules( std::vector<CVAModuleInfo>& m_viModuleInfos )
728
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
729
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_MODULES, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
730
	ClientSendCommand( pMsg );
731
	const int nModules = pMsg->ReadInt();
Jonas Stienen's avatar
Jonas Stienen committed
732
	m_viModuleInfos.clear();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
733
734
735
	m_viModuleInfos.resize( nModules );
	for( int i = 0; i < nModules; i++ )
		pMsg->ReadModuleInfo( m_viModuleInfos[ i ] );
Jonas Stienen's avatar
Jonas Stienen committed
736
737
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
738
void CVANetNetworkProtocol::ServerGetModules()
739
{
Jonas Stienen's avatar
Jonas Stienen committed
740
741
	CVANetMessage* pMsg = ServerGetMessage();
	std::vector<CVAModuleInfo> viModules;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
742
	m_pRealCore->GetModules( viModules );
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
743
744
745
	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
746
747
}

748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
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
764
765
766
767
768
769
770
771
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();
}

772
void CVANetNetworkProtocol::ServerFindFilePath()
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
773
774
775
776
777
778
779
{
	CVANetMessage* pMsg = ServerGetMessage();
	const std::string sFilePath = pMsg->ReadString();
	const std::string sFoundFilePath = m_pRealCore->FindFilePath( sFilePath );
	pMsg->WriteString( sFoundFilePath );
}

780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
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
798
CVAStruct CVANetNetworkProtocol::ClientGetHardwareConfiguration()
799
800
801
802
803
804
805
806
807
808
{
	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
809
	const CVAStruct oHWConfig = m_pRealCore->GetHardwareConfiguration();
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
	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
833
CVAStruct CVANetNetworkProtocol::ClientCallModule( const std::string& sModuleName, const CVAStruct& oArgs )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
834
835
836
837
{
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CALL_MODULE, MESSAGE_WITH_ANSWER );
	pMsg->WriteString( sModuleName );
	pMsg->WriteVAStruct( oArgs );
Jonas Stienen's avatar
Jonas Stienen committed
838
	ClientSendCommand( pMsg );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
839
	CVAStruct oReturn;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
840
	pMsg->ReadVAStruct( oReturn );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
841
	return oReturn;
Jonas Stienen's avatar
Jonas Stienen committed
842
843
844
845
846
847
}

void CVANetNetworkProtocol::ServerCallModule()
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sModuleName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
848
	CVAStruct oArgs;
Jonas Stienen's avatar
Jonas Stienen committed
849
	pMsg->ReadVAStruct( oArgs );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
850
	CVAStruct oReturn = m_pRealCore->CallModule( sModuleName, oArgs );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
851
	pMsg->WriteVAStruct( oReturn );
Jonas Stienen's avatar
Jonas Stienen committed
852
853
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
854
int CVANetNetworkProtocol::ClientCreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName )
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
855
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
856
857
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_DIRECTIVITY, MESSAGE_WITH_ANSWER );
	pMsg->WriteVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
858
859
860
861
862
863
864
	pMsg->WriteString( sName );

	ClientSendCommand( pMsg );

	return pMsg->ReadInt();
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
865
void CVANetNetworkProtocol::ServerCreateDirectivityFromParameters()
Jonas Stienen's avatar
Jonas Stienen committed
866
867
868
{
	CVANetMessage* pMsg = ServerGetMessage();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
869
870
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
871
872
	std::string sName = pMsg->ReadString();

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
873
	const int iDirID = m_pRealCore->CreateDirectivityFromParameters( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
874
875
876
877

	pMsg->WriteInt( iDirID );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
878
bool CVANetNetworkProtocol::ClientDeleteDirectivity( const int iDirID )
Jonas Stienen's avatar
Jonas Stienen committed
879
{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
880
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_DELETE_DIRECTIVITY, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
881
882
883
884
885
886
887
	pMsg->WriteInt( iDirID );

	ClientSendCommand( pMsg );

	return pMsg->ReadBool();
}

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

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

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
894
	const bool bRes = m_pRealCore->DeleteDirectivity( iDirID );
Jonas Stienen's avatar
Jonas Stienen committed
895
896
897
	pMsg->WriteBool( bRes );
}

898
CVADirectivityInfo CVANetNetworkProtocol::ClientGetDirectivityInfo( const int iDirID )
Jonas Stienen's avatar
Jonas Stienen committed
899
{
900
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_DIRECTIVITY_INFO, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
901
902
903
904
905
906
907
908
909
910
911
912
913
	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
914
915

	CVADirectivityInfo oDirInfo = m_pRealCore->GetDirectivityInfo( iDirID );
Jonas Stienen's avatar
Jonas Stienen committed
916
917
918
919

	pMsg->WriteDirectivityInfo( oDirInfo );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
920
void CVANetNetworkProtocol::ClientGetDirectivityInfos( std::vector<CVADirectivityInfo>& vdiDest )
Jonas Stienen's avatar
Jonas Stienen committed
921
{
922
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_DIRECTIVITY_INFOS, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
923
924
	ClientSendCommand( pMsg );
	vdiDest.clear();
925
	const int iNumDirectivities = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
926
	for( int i = 0; i < iNumDirectivities; i++ )
Jonas Stienen's avatar
Jonas Stienen committed
927
928
929
930
931
932
933
		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
934
935
936
937
	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
938
939
}

940
void CVANetNetworkProtocol::ClientSetDirectivityName( const int iID, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
941
{
942
943
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_DIRECTIVITY_NAME, MESSAGE_ALLOWS_BUFFERING );
	pMsg->WriteInt( iID );
Jonas Stienen's avatar
Jonas Stienen committed
944
	pMsg->WriteString( sName );
945
946
947
948
949
950
951
952
953
954
	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
955

956
957
958
959
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
960
	ClientSendCommand( pMsg );
961
962
963
	const std::string sName = pMsg->ReadString();
	return sName;
}
Jonas Stienen's avatar
Jonas Stienen committed
964

965
966
967
968
969
970
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
971
972
}

973
974
975
976
977
978
979
980
981
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
982
983
{
	CVANetMessage* pMsg = ServerGetMessage();
984
985
986
987
	const int iID = pMsg->ReadInt();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
	m_pRealCore->SetDirectivityParameters( iID, oParams );
Jonas Stienen's avatar
Jonas Stienen committed
988

989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
}

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
1006
1007
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
1008
1009
1010
	const CVAStruct oReturn = m_pRealCore->GetDirectivityParameters( iID, oParams );
	pMsg->WriteVAStruct( oReturn );
}
Jonas Stienen's avatar
Jonas Stienen committed
1011

1012
1013
1014
1015
1016
1017
1018
1019
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
1020

1021
1022
1023
1024
1025
1026
1027
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
1028
1029
1030
	pMsg->WriteString( sID );
}

1031
1032
std::string CVANetNetworkProtocol::ClientCreateTextToSpeechSignalSource( const std::string& sName )
{
1033
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_TEXT_TO_SPEECH, MESSAGE_WITH_ANSWER );
1034
1035
1036
1037
1038
1039
1040
1041
1042
	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
1043
	std::string sID = m_pRealCore->CreateSignalSourceTextToSpeech( sName );
1044
1045
1046
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1047
std::string CVANetNetworkProtocol::ClientCreateSequencerSignalSource( const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1048
{
1049
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_SEQUENCER, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1050
1051
1052
1053
1054
1055
1056
1057
1058
	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
1059
	std::string sID = m_pRealCore->CreateSignalSourceSequencer( sName );
Jonas Stienen's avatar
Jonas Stienen committed
1060
1061
1062
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1063
std::string CVANetNetworkProtocol::ClientCreateNetworkStreamSignalSource( const std::string& sInterface, const int iPort, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1064
{
1065
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_NETWORK_STREAM, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083

	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
1084
	std::string iID = m_pRealCore->CreateSignalSourceNetworkStream( sInterface, iPort, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1085

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1086
	pMsg->WriteString( iID );
Jonas Stienen's avatar
Jonas Stienen committed
1087
1088
}

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

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1093
	pMsg->WriteVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
	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
1104
1105
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1106
	std::string sName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1107
	std::string sID = m_pRealCore->CreateSignalSourceEngine( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1108
1109
1110
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1111
std::string CVANetNetworkProtocol::ClientCreateSignalSourceMachine( const CVAStruct& oParams, const std::string& sName )
Jonas Stienen's avatar
Jonas Stienen committed
1112
{
1113
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_CREATE_SIGNAL_SOURCE_MACHINE, MESSAGE_WITH_ANSWER );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1114
1115
1116
1117
1118
	pMsg->WriteVAStruct( oParams );
	pMsg->WriteString( sName );
	ClientSendCommand( pMsg );
	return pMsg->ReadString();
}
Jonas Stienen's avatar
Jonas Stienen committed
1119

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1120
1121
1122
1123
1124
void CVANetNetworkProtocol::ServerCreateSignalSourceMachine()
{
	CVANetMessage* pMsg = ServerGetMessage();
	CVAStruct oParams;
	pMsg->ReadVAStruct( oParams );
Jonas Stienen's avatar
Jonas Stienen committed
1125
	std::string sName = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1126
	std::string sID = m_pRealCore->CreateSignalSourceMachine( oParams, sName );
Jonas Stienen's avatar
Jonas Stienen committed
1127
1128
1129
	pMsg->WriteString( sID );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1130
bool CVANetNetworkProtocol::ClientDeleteSignalSource( const std::string& sID )
Jonas Stienen's avatar
Jonas Stienen committed
1131
{
1132
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_DELETE_SIGNALSOURCE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
	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
1146
std::string CVANetNetworkProtocol::ClientGetSoundSourceSignalSource( const int iSoundSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1147
{
1148
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SOUND_SOURCE_SIGNALSOURCE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1149
1150
1151
1152
1153
1154
1155
1156
	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
1157
	const int iID = pMsg->ReadInt();
Jonas Stienen's avatar
Jonas Stienen committed
1158
1159
1160
1161
	std::string sSignalSourceID = m_pRealCore->GetSoundSourceSignalSource( iID );
	pMsg->WriteString( sSignalSourceID );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1162
CVASignalSourceInfo CVANetNetworkProtocol::ClientGetSignalSourceInfo( const std::string& sSignalSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1163
{
1164
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNALSOURCE_INFO, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
	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
1175
	CVASignalSourceInfo oSignalSourceInfo = m_pRealCore->GetSignalSourceInfo( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
1176
1177
1178
	pMsg->WriteSignalSourceInfo( oSignalSourceInfo );
}

Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1179
void CVANetNetworkProtocol::ClientGetSignalSourceInfos( std::vector<CVASignalSourceInfo>& vssiDest )
Jonas Stienen's avatar
Jonas Stienen committed
1180
{
1181
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNALSOURCE_INFOS, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1182
1183
1184
	ClientSendCommand( pMsg );
	vssiDest.clear();
	int iNumSignalSources = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Style    
Dipl.-Ing. Jonas Stienen committed
1185
	for( int i = 0; i < iNumSignalSources; i++ )
Jonas Stienen's avatar
Jonas Stienen committed
1186
1187
1188
1189
1190
1191
1192
		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
1193
1194
1195
1196
	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
1197
1198
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1199
int CVANetNetworkProtocol::ClientGetSignalSourceBufferPlaybackState( const std::string& sSignalSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1200
{
1201
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNAL_SOURCE_BUFFER_PLAYBACK_STATE, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1202
1203
	pMsg->WriteString( sSignalSourceID );
	ClientSendCommand( pMsg );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1204
	const int iPlayState = pMsg->ReadInt();
Jonas Stienen's avatar
Jonas Stienen committed
1205
1206
1207
	return iPlayState;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1208
void CVANetNetworkProtocol::ServerGetSignalSourceBufferPlaybackState()
Jonas Stienen's avatar
Jonas Stienen committed
1209
1210
1211
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1212
	const int iPlayState = m_pRealCore->GetSignalSourceBufferPlaybackState( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
1213
1214
1215
	pMsg->WriteInt( iPlayState );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1216
void CVANetNetworkProtocol::ClientSetSignalSourceBufferPlaybackAction( const std::string& sSignalSourceID, const int iPlayAction )
Jonas Stienen's avatar
Jonas Stienen committed
1217
{
1218
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNAL_SOURCE_BUFFER_PLAYBACK_ACTION, MESSAGE_ALLOWS_BUFFERING );
Jonas Stienen's avatar
Jonas Stienen committed
1219
1220
1221
1222
1223
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteInt( iPlayAction );
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1224
void CVANetNetworkProtocol::ServerSetSignalSourceBufferPlaybackAction()
Jonas Stienen's avatar
Jonas Stienen committed
1225
1226
1227
1228
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
	int iPlayAction = pMsg->ReadInt();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1229
	m_pRealCore->SetSignalSourceBufferPlaybackAction( sSignalSourceID, iPlayAction );
Jonas Stienen's avatar
Jonas Stienen committed
1230
1231
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1232
void CVANetNetworkProtocol::ClientSetSignalSourceBufferLooping( const std::string& sSignalSourceID, const bool bLooping )
Jonas Stienen's avatar
Jonas Stienen committed
1233
{
1234
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNAL_SOURCE_BUFFER_LOOPING, MESSAGE_ALLOWS_BUFFERING );
Jonas Stienen's avatar
Jonas Stienen committed
1235
1236
1237
1238
1239
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteBool( bLooping );
	ClientSendCommand( pMsg );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1240
void CVANetNetworkProtocol::ServerSetSignalSourceBufferLooping()
Jonas Stienen's avatar
Jonas Stienen committed
1241
1242
1243
1244
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
	bool bLooping = pMsg->ReadBool();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1245
	m_pRealCore->SetSignalSourceBufferLooping( sSignalSourceID, bLooping );
Jonas Stienen's avatar
Jonas Stienen committed
1246
1247
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1248
bool CVANetNetworkProtocol::ClientGetSignalSourceBufferLooping( const std::string& sSignalSourceID )
Jonas Stienen's avatar
Jonas Stienen committed
1249
{
1250
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNAL_SOURCE_BUFFER_LOOPING, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1251
1252
1253
1254
1255
1256
	pMsg->WriteString( sSignalSourceID );
	ClientSendCommand( pMsg );
	bool bLooping = pMsg->ReadBool();
	return bLooping;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1257
void CVANetNetworkProtocol::ServerGetSignalSourceBufferLooping()
Jonas Stienen's avatar
Jonas Stienen committed
1258
1259
1260
{
	CVANetMessage* pMsg = ServerGetMessage();
	std::string sSignalSourceID = pMsg->ReadString();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1261
	bool bLooping = m_pRealCore->GetSignalSourceBufferLooping( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
1262
1263
1264
	pMsg->WriteBool( bLooping );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1265
void CVANetNetworkProtocol::ClientSetSignalSourceBufferPlaybackPosition( const std::string& sSignalSourceID, const double dPlaybackPosition )
Jonas Stienen's avatar
Jonas Stienen committed
1266
{
1267
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_SET_SIGNAL_SOURCE_BUFFER_PLAYBACK_POSITION, MESSAGE_ALLOWS_BUFFERING );
Jonas Stienen's avatar
Jonas Stienen committed
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
	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
1278
	m_pRealCore->SetSignalSourceBufferPlaybackPosition( sSignalSourceID, dPlaybackPosition );
Jonas Stienen's avatar
Jonas Stienen committed
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
}

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 )
{
1302
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_GET_SIGNAL_SOURCE_PARAMETERS, MESSAGE_WITH_ANSWER );
Jonas Stienen's avatar
Jonas Stienen committed
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
	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;
}

1322
1323
int CVANetNetworkProtocol::ClientAddSignalSourceSequencerSample( const std::string& sSignalSourceID, const CVAStruct& oArgs )
{
1324
1325
1326
1327
1328
	CVANetMessage* pMsg = ClientInitMessage( VA_NP_ADD_SIGNAL_SOURCE_SEQUENCER_SAMPLE, MESSAGE_WITH_ANSWER );
	pMsg->WriteString( sSignalSourceID );
	pMsg->WriteVAStruct( oArgs );
	ClientSendCommand( pMsg );
	return pMsg->ReadInt();
1329
1330
1331
1332
}

void CVANetNetworkProtocol::ServerAddSignalSourceSequencerSample()
{