Commit 6f46689c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Progress

parent d1d8e436
......@@ -16,7 +16,6 @@
#include <VANetDefinitions.h>
#include <VABaseDefinitions.h>
#include <VABase.h>
#include <VASamples.h>
......
......@@ -17,7 +17,7 @@
#include <VANetDefinitions.h>
#include <string>
class IVACore;
class IVAInterface;
class CVANetNetworkProtocol;
/**
......@@ -75,7 +75,7 @@ public:
virtual ~IVANetClient();
// Client-seitige VACore-Instanz zurckgeben
virtual IVACore* GetCoreInstance() const = 0;
virtual IVAInterface* GetCoreInstance() const = 0;
// Gibt zurck, ob eine Verbindung zu einem Server besteht
virtual bool IsConnected() const = 0;
......@@ -86,9 +86,9 @@ public:
// Client initialisieren und mit einem Server verbinden
// (Rckgabe: Statuscode)
virtual int Initialize( const std::string& sServerAddress, int iServerPort = VANET_DEFAULT_PORT, int iHeadChannelMode = VA_HC_USE_EXISTING, int IExceptionHandlingMode = EXC_CLIENT_THROW, bool bBufferSynchronizedCommands = true ) = 0;
virtual int Initialize( const std::string& sServerAddress, const int iServerPort = VANET_DEFAULT_PORT, const int iHeadChannelMode = VA_HC_USE_EXISTING, const int IExceptionHandlingMode = EXC_CLIENT_THROW, const bool bBufferSynchronizedCommands = true ) = 0;
virtual void SetExceptionHandlingMode( int nMode ) = 0;
virtual void SetExceptionHandlingMode( const int nMode ) = 0;
virtual int GetExceptionhandlingMode() const = 0;
// Vorhandene Serververbindung beenden
......@@ -105,8 +105,8 @@ public:
EVENT_SERVER_LOST // Ungewollter Verbindungsabbruch
};
int iType; // Typ der Ereignisses
std::string sServer; //
int iType;
inline CEvent()
: iType( EVENT_NOTHING )
......
This diff is collapsed.
......@@ -20,7 +20,7 @@
class VistaConnectionIP;
class CVANetNetworkProtocol;
class IVACoreEventHandler;
class IVAEventHandler;
class VistaMutex;
/**
......@@ -33,30 +33,30 @@ public:
CVANetClientImpl();
~CVANetClientImpl();
IVACore* GetCoreInstance() const;
IVAInterface* GetCoreInstance() const;
bool IsConnected() const;
std::string GetServerAddress() const;
int Initialize( const std::string& sServerAddress, int iServerPort, int iHeadChannelMode = VA_HC_USE_EXISTING, int IExceptionHandlingMode = EXC_CLIENT_THROW, bool bBufferSynchronizedCommands = true );
int Initialize( const std::string& sServerAddress, const int iServerPort, const int iHeadChannelMode = VA_HC_USE_EXISTING, const int IExceptionHandlingMode = EXC_CLIENT_THROW, const bool bBufferSynchronizedCommands = true );
int Disconnect();
void SendConnectionEvent( int nId );
void AttachCoreEventHandler(IVACoreEventHandler* pCoreEventHandler);
void DetachCoreEventHandler(IVACoreEventHandler* pCoreEventHandler);
void AttachCoreEventHandler( IVAEventHandler* pCoreEventHandler );
void DetachCoreEventHandler( IVAEventHandler* pCoreEventHandler );
virtual bool AttachEventHandler(IVANetClient::IEventHandler* pHandler);
virtual bool DetachEventHandler(IVANetClient::IEventHandler* pHandler);
virtual bool AttachEventHandler( IVANetClient::IEventHandler* pHandler );
virtual bool DetachEventHandler( IVANetClient::IEventHandler* pHandler );
virtual void SetExceptionHandlingMode( int nMode );
virtual void SetExceptionHandlingMode( const int nMode );
virtual int GetExceptionhandlingMode() const;
void ProcessNetEvent( int iEventID );
void ProcessEventChannelError();
private:
void Cleanup();
void Cleanup();
void EmitEvent( const CEvent& oEvent );
void EmitEvent( int iID );
void EmitEvent( const int iID );
protected:
class CNetworkedVACore;
......
......@@ -15,10 +15,6 @@
#include "VANetNetworkProtocol.h"
#include <VACoreEvent.h>
#include <VAException.h>
#include <VACoreVersion.h>
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaExceptionBase.h>
#include <VistaBase/VistaStreamUtils.h>
......@@ -28,7 +24,7 @@
static int S_nMessageIds = 0;
CVANetMessage::CVANetMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers )
CVANetMessage::CVANetMessage( const VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers )
: m_vecIncomingBuffer( 2048 )
, m_oOutgoing( 2048 )
, m_pConnection( NULL )
......@@ -145,7 +141,7 @@ void CVANetMessage::ReadMessage()
iBytesRead = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ iBytesReadTotal ], nMessageSize - iBytesReadTotal ); // read residual bytes
else
iBytesRead = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ iBytesReadTotal ], iIncommingBytes ); // read all incoming bytes
iBytesReadTotal += iBytesRead;
}
assert( iBytesReadTotal == nMessageSize );
......@@ -335,11 +331,12 @@ void CVANetMessage::WriteVec3( const VAVec3& oVec )
WriteDouble( oVec.z );
}
void CVANetMessage::WriteOrient( const VAOrientYPR& oOrient )
void CVANetMessage::WriteQuat( const VAQuat& qOrient )
{
WriteDouble( oOrient.yaw );
WriteDouble( oOrient.pitch );
WriteDouble( oOrient.roll );
WriteDouble( qOrient.x );
WriteDouble( qOrient.y );
WriteDouble( qOrient.z );
WriteDouble( qOrient.w );
}
std::string CVANetMessage::ReadString()
......@@ -406,15 +403,16 @@ VAVec3 CVANetMessage::ReadVec3()
return VAVec3( x, y, z );
}
VAOrientYPR CVANetMessage::ReadOrient()
VAQuat CVANetMessage::ReadQuat()
{
double yaw = ReadDouble();
double pitch = ReadDouble();
double roll = ReadDouble();
return VAOrientYPR( yaw, pitch, roll );
double x = ReadDouble();
double y = ReadDouble();
double z = ReadDouble();
double w = ReadDouble();
return VAQuat( x, y, z, w );
}
void CVANetMessage::WriteCoreEvent( const CVACoreEvent& oEvent )
void CVANetMessage::WriteEvent( const CVAEvent& oEvent )
{
WriteInt( oEvent.iEventID );
WriteUInt64( oEvent.iEventType );
......@@ -432,8 +430,7 @@ void CVANetMessage::WriteCoreEvent( const CVACoreEvent& oEvent )
WriteVec3( oEvent.vPos );
WriteVec3( oEvent.vView );
WriteVec3( oEvent.vUp );
WriteOrient( oEvent.oOrientation );
WriteVec3( oEvent.vVelocity );
WriteQuat( oEvent.oOrientation );
WriteInt( ( int ) oEvent.vfInputPeaks.size() );
for( size_t i = 0; i < oEvent.vfInputPeaks.size(); i++ )
......@@ -447,9 +444,9 @@ void CVANetMessage::WriteCoreEvent( const CVACoreEvent& oEvent )
WriteDouble( oEvent.dCoreClock );
}
CVACoreEvent CVANetMessage::ReadCoreEvent()
CVAEvent CVANetMessage::ReadEvent()
{
CVACoreEvent oEvent;
CVAEvent oEvent;
oEvent.iEventID = ReadInt();
oEvent.iEventType = ReadUInt64();
oEvent.iObjectID = ReadInt();
......@@ -466,8 +463,7 @@ CVACoreEvent CVANetMessage::ReadCoreEvent()
oEvent.vPos = ReadVec3();
oEvent.vView = ReadVec3();
oEvent.vUp = ReadVec3();
oEvent.oOrientation = ReadOrient();
oEvent.vVelocity = ReadVec3();
oEvent.oOrientation = ReadQuat();
int n = ReadInt();
for( int i = 0; i < n; i++ )
......@@ -498,7 +494,7 @@ CVAException CVANetMessage::ReadException()
return CVAException( nType, ReadString() );
}
void CVANetMessage::WriteCoreVersionInfo( const CVACoreVersionInfo& oInfo )
void CVANetMessage::WriteVersionInfo( const CVAVersionInfo& oInfo )
{
WriteString( oInfo.sVersion );
WriteString( oInfo.sFlags );
......@@ -506,9 +502,9 @@ void CVANetMessage::WriteCoreVersionInfo( const CVACoreVersionInfo& oInfo )
WriteString( oInfo.sComments );
}
CVACoreVersionInfo CVANetMessage::ReadCoreVersionInfo()
CVAVersionInfo CVANetMessage::ReadVersionInfo()
{
CVACoreVersionInfo oInfo;
CVAVersionInfo oInfo;
oInfo.sVersion = ReadString();
oInfo.sFlags = ReadString();
oInfo.sDate = ReadString();
......@@ -519,7 +515,6 @@ CVACoreVersionInfo CVANetMessage::ReadCoreVersionInfo()
void CVANetMessage::WriteDirectivityInfo( const CVADirectivityInfo& oInfo )
{
WriteString( oInfo.sName );
WriteString( oInfo.sFilename );
WriteInt( oInfo.iID );
WriteInt( oInfo.iReferences );
WriteString( oInfo.sDesc );
......@@ -529,57 +524,15 @@ CVADirectivityInfo CVANetMessage::ReadDirectivityInfo()
{
CVADirectivityInfo oInfo;
oInfo.sName = ReadString();
oInfo.sFilename = ReadString();
oInfo.iID = ReadInt();
oInfo.iReferences = ReadInt();
oInfo.sDesc = ReadString();
return oInfo;
}
void CVANetMessage::WriteHRIRInfo( const CVAHRIRInfo& oInfo )
{
WriteString( oInfo.sName );
WriteString( oInfo.sFilename );
WriteInt( oInfo.iID );
WriteInt( oInfo.iReferences );
WriteString( oInfo.sDesc );
}
CVAHRIRInfo CVANetMessage::ReadHRIRInfo()
{
CVAHRIRInfo oInfo;
oInfo.sName = ReadString();
oInfo.sFilename = ReadString();
oInfo.iID = ReadInt();
oInfo.iReferences = ReadInt();
oInfo.sDesc = ReadString();
return oInfo;
}
void CVANetMessage::WriteSoundInfo( const CVASoundInfo& oInfo )
{
WriteString( oInfo.sName );
WriteString( oInfo.sFilename );
WriteInt( oInfo.iLength );
WriteInt( oInfo.iID );
WriteDouble( oInfo.dDuration );
}
CVASoundInfo CVANetMessage::ReadSoundInfo()
{
CVASoundInfo oInfo;
oInfo.sName = ReadString();
oInfo.sFilename = ReadString();
oInfo.iLength = ReadInt();
oInfo.iID = ReadInt();
oInfo.dDuration = ReadDouble();
return oInfo;
}
void CVANetMessage::WriteSignalSourceInfo( const CVASignalSourceInfo& oInfo )
{
WriteString( oInfo.sName );
WriteString( oInfo.sType );
WriteString( oInfo.sState );
WriteString( oInfo.sID );
WriteString( oInfo.sDesc );
......@@ -590,7 +543,6 @@ CVASignalSourceInfo CVANetMessage::ReadSignalSourceInfo()
{
CVASignalSourceInfo oInfo;
oInfo.sName = ReadString();
oInfo.sType = ReadString();
oInfo.sState = ReadString();
oInfo.sID = ReadString();
oInfo.sDesc = ReadString();
......@@ -686,7 +638,7 @@ void CVANetMessage::WriteVAStruct( const CVAStruct& oStruct )
for( int i = 0; i < oSampleBuffer.GetNumSamples(); i++ )
WriteFloat( oSampleBuffer.vfSamples[ i ] );
}
break;
break;
default:
// Implementierung vergessen? Oder neuer Datentyp?
......@@ -738,7 +690,7 @@ void CVANetMessage::ReadVAStruct( CVAStruct& oStruct )
ReadVAStruct( oSubstruct );
oStruct[ sKeyName ] = oSubstruct;
}
break;
break;
case CVAStructValue::DATA:
{
......@@ -755,7 +707,7 @@ void CVANetMessage::ReadVAStruct( CVAStruct& oStruct )
}
oStruct[ sKeyName ] = CVAStructValue( pData, iDataSize );
}
break;
break;
case CVAStructValue::SAMPLEBUFFER:
{
......@@ -765,7 +717,7 @@ void CVANetMessage::ReadVAStruct( CVAStruct& oStruct )
for( int i = 0; i < iNumSamples; i++ )
oSampleBuffer.vfSamples[ i ] = ReadFloat();
}
break;
break;
default:
// Implementierung vergessen? Oder neuer Datentyp?
......
......@@ -14,9 +14,7 @@
#ifndef IW_VANET_MESSAGE
#define IW_VANET_MESSAGE
#include <VABaseDefinitions.h>
#include <VABase.h>
#include <VAStruct.h>
#include <VA.h>
#include "VANetVistaCompatibility.h"
......@@ -29,12 +27,10 @@
class VistaConnectionIP;
class CVACoreEvent;
class CVAEvent;
class CVAException;
class CVACoreVersionInfo;
class CVAVersionInfo;
class CVADirectivityInfo;
class CVAHRIRInfo;
class CVASoundInfo;
class CVASignalSourceInfo;
class CVASceneInfo;
......@@ -46,7 +42,7 @@ class CVASceneInfo;
class CVANetMessage
{
public:
explicit CVANetMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers );
explicit CVANetMessage( const VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers );
void ResetMessage();
......@@ -61,9 +57,9 @@ public:
int GetMessageType() const;
int GetAnswerType() const;
void SetExceptionMode( int nMode );
void SetMessageType( int nType );
void SetAnswerType( int nType );
void SetExceptionMode( const int nMode );
void SetMessageType( const int nType );
void SetAnswerType( const int nType );
int GetIncomingMessageSize() const;
int GetOutgoingMessageSize() const;
......@@ -79,13 +75,11 @@ public:
void WriteFloat( const float fValue );
void WriteDouble( const double fValue );
void WriteVec3( const VAVec3& oVec );
void WriteOrient( const VAOrientYPR& oOrient );
void WriteQuat( const VAQuat& qOrient );
void WriteException( const CVAException& oException );
void WriteCoreEvent( const CVACoreEvent& oEvent );
void WriteCoreVersionInfo( const CVACoreVersionInfo& oInfo );
void WriteEvent( const CVAEvent& oEvent );
void WriteVersionInfo( const CVAVersionInfo& oInfo );
void WriteDirectivityInfo( const CVADirectivityInfo& oInfo );
void WriteHRIRInfo( const CVAHRIRInfo& oInfo );
void WriteSoundInfo( const CVASoundInfo& oInfo );
void WriteSignalSourceInfo( const CVASignalSourceInfo& oInfo );
void WriteSceneInfo( const CVASceneInfo& oInfo );
void WriteModuleInfo( const CVAModuleInfo& oInfo );
......@@ -101,13 +95,11 @@ public:
float ReadFloat();
double ReadDouble();
VAVec3 ReadVec3();
VAOrientYPR ReadOrient();
VAQuat ReadQuat();
CVAException ReadException();
CVACoreEvent ReadCoreEvent();
CVACoreVersionInfo ReadCoreVersionInfo();
CVAEvent ReadEvent();
CVAVersionInfo ReadVersionInfo();
CVADirectivityInfo ReadDirectivityInfo();
CVAHRIRInfo ReadHRIRInfo();
CVASoundInfo ReadSoundInfo();
CVASignalSourceInfo ReadSignalSourceInfo();
CVASceneInfo ReadSceneInfo();
void ReadModuleInfo( CVAModuleInfo& oInfo );
......
This diff is collapsed.
This diff is collapsed.
......@@ -25,39 +25,33 @@ class VistaConnectionUpdater;
class CVANetNetworkProtocol;
class VistaMutex;
class CVANetServerImpl : public IVANetServer {
class CVANetServerImpl : public IVANetServer
{
public:
CVANetServerImpl();
~CVANetServerImpl();
int Initialize(const std::string& sInterface,
int iServerPort,
int iFreePortMin=10000,
int iFreePortMax=11000,
int iMaxNumClients = -1);
int Initialize(const std::string& sInterface,
int iServerPort,
const tPortList& liFreePorts,
int iMaxNumClients = -1);
int Initialize( const std::string& sInterface, const int iServerPort, const int iFreePortMin = 10000, const int iFreePortMax = 11000, const int iMaxNumClients = -1 );
int Initialize( const std::string& sInterface, const int iServerPort, const tPortList& liFreePorts, const int iMaxNumClients = -1 );
int Finalize();
void Reset();
std::string GetServerAdress() const;
int GetServerPort() const;
IVACore* GetCoreInstance() const;
void SetCoreInstance(IVACore* pCore);
IVAInterface* GetCoreInstance() const;
void SetCoreInstance( IVAInterface* pCore );
bool IsClientConnected() const;
int GetNumConnectedClients() const;
std::string GetClientHostname(const int iClientIndex) const;
std::string GetClientHostname( const int iClientIndex ) const;
bool AttachEventHandler(IVANetServer::IEventHandler* pHandler);
bool DetachEventHandler(IVANetServer::IEventHandler* pHandler);
bool AttachEventHandler( IVANetServer::IEventHandler* pHandler );
bool DetachEventHandler( IVANetServer::IEventHandler* pHandler );
bool AttachCoreEventHandler(VistaConnectionIP* pConnection);
bool DetachCoreEventHandler(VistaConnectionIP* pConnection);
bool AttachCoreEventHandler( VistaConnectionIP* pConnection );
bool DetachCoreEventHandler( VistaConnectionIP* pConnection );
void HandleClientEvent(int iEventID, VistaConnectionIP* pConnection);
void HandleClientEvent( int iEventID, VistaConnectionIP* pConnection );
protected:
int AddNewClient( VistaConnectionIP* pTemporaryConnection );
......@@ -67,7 +61,7 @@ protected:
void EmitEvent( const CEvent& oEvent );
protected:
class CConnectionObserver;
class CConnectionAccepter;
......@@ -82,17 +76,17 @@ protected:
};
private:
CConnectionAccepter* m_pConnectionAccepter;
CConnectionObserver* m_pConnObserver;
CEventHandler* m_pEventHandler;
CConnectionAccepter* m_pConnectionAccepter;
CConnectionObserver* m_pConnObserver;
CEventHandler* m_pEventHandler;
std::vector<CClientData> m_vecClients;
bool m_bInitialized;
bool m_bRunning;
int m_iMaxNumClients;
IVACore* m_pRealCore;
CVANetNetworkProtocol* m_pProtocol;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment