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

Finished client server init until some values are exchanged.

parent d37462eb
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
static int S_nMessageIds = 0; static int S_nMessageIds = 0;
CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers ) CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers )
: m_vecIncomingBuffer() : m_vecIncomingBuffer( 2048 )
, m_oOutgoing() , m_oOutgoing( 2048 )
, m_pConnection( NULL ) , m_pConnection( NULL )
{ {
m_oOutgoing.SetByteorderSwapFlag( bSwapBuffers ); m_oOutgoing.SetByteorderSwapFlag( bSwapBuffers );
...@@ -37,7 +37,6 @@ void CITANetAudioMessage::ResetMessage() ...@@ -37,7 +37,6 @@ void CITANetAudioMessage::ResetMessage()
m_oOutgoing.ClearBuffer(); m_oOutgoing.ClearBuffer();
m_oOutgoing.WriteInt32( 0 ); // size dummy m_oOutgoing.WriteInt32( 0 ); // size dummy
m_oOutgoing.WriteInt32( 0 ); // type dummy m_oOutgoing.WriteInt32( 0 ); // type dummy
m_oOutgoing.WriteInt32( 0 ); // exceptmode dummy
m_oOutgoing.WriteInt32( 0 ); // ID m_oOutgoing.WriteInt32( 0 ); // ID
m_oIncoming.SetBuffer( NULL, 0 ); m_oIncoming.SetBuffer( NULL, 0 );
...@@ -82,8 +81,8 @@ void CITANetAudioMessage::WriteMessage() ...@@ -82,8 +81,8 @@ void CITANetAudioMessage::WriteMessage()
try try
{ {
int nRet = m_pConnection->WriteRawBuffer( m_oOutgoing.GetBuffer(), int iRawBufferSize = m_oOutgoing.GetBufferSize();
m_oOutgoing.GetBufferSize() ); int nRet = m_pConnection->WriteRawBuffer( m_oOutgoing.GetBuffer(), iRawBufferSize );
m_pConnection->WaitForSendFinish(); m_pConnection->WaitForSendFinish();
if( nRet != m_oOutgoing.GetBufferSize() ) if( nRet != m_oOutgoing.GetBufferSize() )
ITA_EXCEPT1( NETWORK_ERROR, "Could not write the expected number of bytes" ); ITA_EXCEPT1( NETWORK_ERROR, "Could not write the expected number of bytes" );
...@@ -196,6 +195,7 @@ void CITANetAudioMessage::ReadAnswer() ...@@ -196,6 +195,7 @@ void CITANetAudioMessage::ReadAnswer()
if( nMessageSize > ( int ) m_vecIncomingBuffer.size() ) if( nMessageSize > ( int ) m_vecIncomingBuffer.size() )
m_vecIncomingBuffer.resize( nMessageSize ); m_vecIncomingBuffer.resize( nMessageSize );
// jst: hier nicht while( nReturn < nMessageSize) ReadRawBuffer??
nReturn = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ 0 ], nMessageSize ); nReturn = m_pConnection->ReadRawBuffer( &m_vecIncomingBuffer[ 0 ], nMessageSize );
if( nReturn != nMessageSize ) if( nReturn != nMessageSize )
ITA_EXCEPT1( UNKNOWN, "Protokoll error, Received less bytes than expected" ); ITA_EXCEPT1( UNKNOWN, "Protokoll error, Received less bytes than expected" );
...@@ -216,7 +216,6 @@ void CITANetAudioMessage::ReadAnswer() ...@@ -216,7 +216,6 @@ void CITANetAudioMessage::ReadAnswer()
try try
{ {
m_nAnswerType = ReadInt(); // TODO: assert weg, dafr Kontrolle falls Server crasht< m_nAnswerType = ReadInt(); // TODO: assert weg, dafr Kontrolle falls Server crasht<
ReadInt(); // protocol overhead - just read and ignore
int nMessageID = ReadInt(); int nMessageID = ReadInt();
assert( nMessageID == m_nMessageId ); assert( nMessageID == m_nMessageId );
m_nMessageId = nMessageID; m_nMessageId = nMessageID;
......
...@@ -44,18 +44,21 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor ...@@ -44,18 +44,21 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
// Validate streaming parameters of server and client // Validate streaming parameters of server and client
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN ); m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN );
m_pMessage->WriteStreamingParameters( m_oClientParams ); //m_pMessage->WriteStreamingParameters( m_oClientParams ); // Not yet
m_pMessage->WriteInt( 42 );
m_pMessage->WriteMessage(); m_pMessage->WriteMessage();
m_pMessage->ReadAnswer(); m_pMessage->ReadAnswer();
assert( m_pMessage->GetAnswerType() == CITANetAudioProtocol::NP_SERVER_OPEN ); assert( m_pMessage->GetAnswerType() == CITANetAudioProtocol::NP_SERVER_OPEN );
bool bOK = m_pMessage->ReadBool(); int i42 = m_pMessage->ReadInt();
/* Not yet
CITANetAudioProtocol::StreamingParameters oServerParams = m_pMessage->ReadStreamingParameters(); CITANetAudioProtocol::StreamingParameters oServerParams = m_pMessage->ReadStreamingParameters();
if( oServerParams == m_oClientParams ) if( oServerParams == m_oClientParams )
m_oServerParams = oServerParams; m_oServerParams = oServerParams;
else else
ITA_EXCEPT1( INVALID_PARAMETER, "Streaming parameters of network audio server and client do not match." ); ITA_EXCEPT1( INVALID_PARAMETER, "Streaming parameters of network audio server and client do not match." );
*/
Run(); Run();
......
...@@ -24,35 +24,34 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer() ...@@ -24,35 +24,34 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
, m_pConnection( NULL ) , m_pConnection( NULL )
{ {
m_pNetAudioServer = new CITANetAudioServer(); m_pNetAudioServer = new CITANetAudioServer();
m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES );
} }
bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort ) bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort )
{ {
// TODO: vorrckgabe noch anfangen zu senden (Samples) // TODO: vorrckgabe noch anfangen zu senden (Samples)
if( m_pNetAudioServer->Start( sAddress, iPort ) ) if( !m_pNetAudioServer->Start( sAddress, iPort ) ) // blocking
{ return false;
m_pConnection = m_pNetAudioServer->GetConnection(); m_pConnection = m_pNetAudioServer->GetConnection();
m_pMessage = new CITANetAudioMessage( m_pConnection->GetByteorderSwapFlag() );
m_pMessage->ResetMessage(); m_pMessage->ResetMessage();
m_pMessage->SetConnection( m_pConnection ); m_pMessage->SetConnection( m_pConnection );
m_pMessage->ReadMessage(); m_pMessage->ReadMessage(); // blocking
int nMT = m_pMessage->GetMessageType(); int nMT = m_pMessage->GetMessageType();
assert( nMT == CITANetAudioProtocol::NP_CLIENT_OPEN ); assert( nMT == CITANetAudioProtocol::NP_CLIENT_OPEN );
int i42 = m_pMessage->ReadInt();
CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters(); //CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters();
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_OPEN ); m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_OPEN );
m_pMessage->WriteBool( true ); m_pMessage->WriteInt( 2 * 42 );
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
Run(); Run();
return true; return true;
}
return false;
} }
bool CITANetAudioStreamingServer::IsClientConnected() const bool CITANetAudioStreamingServer::IsClientConnected() const
......
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