From 65d61f1c0e822e9de944dc183114c94152a2985f Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Thu, 17 Sep 2009 19:15:56 +0000 Subject: [PATCH] implementation of channel name request message, required if server is restarted while client thinks it is still connected --- src/audiomixerboard.cpp | 2 +- src/channel.cpp | 6 +++++- src/channel.h | 6 ++++-- src/client.cpp | 9 +++------ src/client.h | 3 ++- src/protocol.cpp | 18 ++++++++++++++++++ src/protocol.h | 4 ++++ src/res/faderhandle.png | Bin 0 -> 2012 bytes src/resources.qrc | 3 +++ src/server.cpp | 32 ++++++++++++-------------------- 10 files changed, 52 insertions(+), 31 deletions(-) create mode 100755 src/res/faderhandle.png diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index f9ba7f76..23447d78 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -43,7 +43,7 @@ CChannelFader::CChannelFader ( QWidget* pNW, // TEST custom slider made of custom bitmaps pFader->setStyleSheet ( "QSlider::groove { image: url(:/png/LEDs/res/CLEDYellowSmall.png) }" - "QSlider::handle { image: url(:/png/LEDs/res/CLEDGreySmall.png) }" ); + "QSlider::handle { image: url(:/png/fader/res/faderhandle.png) }" ); */ diff --git a/src/channel.cpp b/src/channel.cpp index f8f17ee0..b4c6378b 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -63,6 +63,10 @@ CChannel::CChannel ( const bool bNIsServer ) : SIGNAL ( ReqJittBufSize() ), SIGNAL ( ReqJittBufSize() ) ); + QObject::connect ( &Protocol, + SIGNAL ( ReqChanName() ), + SIGNAL ( ReqChanName() ) ); + QObject::connect ( &Protocol, SIGNAL ( ReqConnClientsList() ), SIGNAL ( ReqConnClientsList() ) ); @@ -402,7 +406,7 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, bNewConnection = !IsConnected(); // reset time-out counter - iConTimeOut = iConTimeOutStartVal; + ResetTimeOutCounter(); } Mutex.unlock(); } diff --git a/src/channel.h b/src/channel.h index 615c3a2c..ce397304 100755 --- a/src/channel.h +++ b/src/channel.h @@ -68,6 +68,7 @@ public: CVector PrepSendPacket ( const CVector& vecbyNPacket ); + void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; } bool IsConnected() const { return iConTimeOut > 0; } void SetEnable ( const bool bNEnStat ); @@ -79,8 +80,8 @@ public: void SetName ( const QString sNNa ); QString GetName(); - void SetRemoteName ( const QString strName ) - { Protocol.CreateChanNameMes ( strName ); } + void SetRemoteName ( const QString strName ) { Protocol.CreateChanNameMes ( strName ); } + void CreateReqChanNameMes() { Protocol.CreateReqChanNameMes(); } void SetGain ( const int iChanID, const double dNewGain ); double GetGain ( const int iChanID ); @@ -175,6 +176,7 @@ signals: void ReqConnClientsList(); void ConClientListMesReceived ( CVector vecChanInfo ); void NameHasChanged(); + void ReqChanName(); void ChatTextReceived ( QString strChatText ); void PingReceived ( int iMs ); void ReqNetTranspProps(); diff --git a/src/client.cpp b/src/client.cpp index 986bb42d..9688b3db 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -64,6 +64,9 @@ CClient::CClient ( const quint16 iPortNumber ) : QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ), this, SLOT ( OnReqJittBufSize() ) ); + QObject::connect ( &Channel, SIGNAL ( ReqChanName() ), + this, SLOT ( OnReqChanName() ) ); + QObject::connect ( &Channel, SIGNAL ( ConClientListMesReceived ( CVector ) ), SIGNAL ( ConClientListMesReceived ( CVector ) ) ); @@ -92,12 +95,6 @@ void CClient::OnSendProtMessage ( CVector vecMessage ) Socket.SendPacket ( vecMessage, Channel.GetAddress() ); } -void CClient::OnReqJittBufSize() -{ -// TODO cant we implement this OnReqJjittBufSize inside the channel object? - Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); -} - void CClient::OnNewConnection() { // a new connection was successfully initiated, send name and request diff --git a/src/client.h b/src/client.h index 56e4a906..b71e2def 100755 --- a/src/client.h +++ b/src/client.h @@ -202,7 +202,8 @@ protected: public slots: void OnSendProtMessage ( CVector vecMessage ); - void OnReqJittBufSize(); + void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); } + void OnReqChanName() { Channel.SetRemoteName ( strName ); } void OnNewConnection(); void OnReceivePingMessage ( int iMs ); void OnSndCrdReinitRequest(); diff --git a/src/protocol.cpp b/src/protocol.cpp index ce0c62bb..db4bbc78 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -91,6 +91,7 @@ MESSAGES | 2 bytes number n | n bytes UTF-8 string | +------------------+----------------------+ +- Request name of channel: PROTMESSID_REQ_CHANNEL_NAME - Chat text: PROTMESSID_CHAT_TEXT @@ -385,6 +386,10 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; bRet = EvaluateChanNameMes ( vecData ); break; + case PROTMESSID_REQ_CHANNEL_NAME: + bRet = EvaluateReqChanNameMes ( vecData ); + break; + case PROTMESSID_CHAT_TEXT: bRet = EvaluateChatTextMes ( vecData ); break; @@ -692,6 +697,19 @@ bool CProtocol::EvaluateChanNameMes ( const CVector& vecData ) return false; // no error } +void CProtocol::CreateReqChanNameMes() +{ + CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_NAME, CVector ( 0 ) ); +} + +bool CProtocol::EvaluateReqChanNameMes ( const CVector& vecData ) +{ + // invoke message action + emit ReqChanName(); + + return false; // no error +} + void CProtocol::CreateChatTextMes ( const QString strChatText ) { unsigned int iPos = 0; // init position pointer diff --git a/src/protocol.h b/src/protocol.h index b4381fb5..d398efcf 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -51,6 +51,7 @@ #define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport #define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport #define PROTMESSID_DISCONNECTION 22 // disconnection +#define PROTMESSID_REQ_CHANNEL_NAME 23 // request channel name for fader tag // lengths of message as defined in protocol.cpp file #define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) @@ -77,6 +78,7 @@ public: void CreateServerFullMes(); void CreateReqConnClientsList(); void CreateChanNameMes ( const QString strName ); + void CreateReqChanNameMes(); void CreateChatTextMes ( const QString strChatText ); void CreatePingMes ( const int iMs ); void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps ); @@ -147,6 +149,7 @@ protected: bool EvaluateServerFullMes ( const CVector& vecData ); bool EvaluateReqConnClientsList ( const CVector& vecData ); bool EvaluateChanNameMes ( const CVector& vecData ); + bool EvaluateReqChanNameMes ( const CVector& vecData ); bool EvaluateChatTextMes ( const CVector& vecData ); bool EvaluatePingMes ( const CVector& vecData ); bool EvaluateNetwTranspPropsMes ( const CVector& vecData ); @@ -178,6 +181,7 @@ signals: void ServerFull(); void ReqConnClientsList(); void ChangeChanName ( QString strName ); + void ReqChanName(); void ChatTextReceived ( QString strChatText ); void PingReceived ( int iMs ); void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); diff --git a/src/res/faderhandle.png b/src/res/faderhandle.png new file mode 100755 index 0000000000000000000000000000000000000000..2382059bba52128104d313934557372361829f59 GIT binary patch literal 2012 zcmV<22P622P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXY` z5iAHcUY{2L00&%2L_t(o!_AmWk6cF;$A71)ZujkZIDw5tAXq^bC=$rtAi!n?_J)Ue zZSfKz#5PhED4zhy-@`j#jf5p)6e$u$*oZ_iM7HH1WUxIm&UpG()j2Gx?(I80(=%gO z;BHO#nYy>@o;t7p{~TfeOL)H5VfWk8bzAW}1#tYIU!fPSUAuPf(xpp(QdLA``1|M| z|77>$rvRuKs#;`Kk}3jZ&1hPz_j|#NOVLhQQR{i%V}TSl&2xgsegu3o*W z+uPfiDNmp7va_>;bB^8JU3Q*+jEJC`NtzL)J}5(#ZIF$<`5fmQPo6x%dC#fMO@8*% zpL`zJtqN=d^T7i1`J5Ods*3lXwrvp+nxdM(2%6LWQ)dMM&5Bja#FQ`*OcgVu zo6p&sOpbPe_a5g;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7h z5Q+)s@~YXU zyg<&GrU?VKw{6R;ZBbLidDhw%qjbYPH*DLMwY4=SlS!E=<#bqMa*&p%nAqOl#(U50 zTerFK_KkYFj@U(VR?eOK66epKFTkZ*Hm^9MIpIU#55Iq#cW?d?fY&~EmRZ{}qL;Fg z6^9ULng$Umb0JrvH>HNyBvh5n%}q|7I#uRFYN#dzA?ITH5CSi~{4x!t5KSwpI_HlZ zH1<{E%isO}58lBH&6yMvP)2Prc9xf-KgerF>L)1{qI1%RaIgfX? ze_8kcaAbks_46VbEv^BtRQdABSm>b>(PcBsA;0}C@X?DkDXoD1tjhO*&#uT{Ib_|I z)>qAt`!U_Kores/VRLEDYellow.png res/VRLEDYellowSmall.png + + res/faderhandle.png + res/gig.png res/mainicon.png diff --git a/src/server.cpp b/src/server.cpp index ea84c278..ad21242d 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -688,25 +688,24 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, case PS_PROT_ERR: PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW, iCurChanID ); - -// TEST -bAudioOK = true; - break; } } - // after data is put in channel buffer, create channel list message if - // requested - if ( bNewChannelReserved && bAudioOK ) + // act on new channel connection + if ( bNewChannelReserved ) { // logging of new connected channel Logging.AddNewConnection ( HostAdr.InetAddr ); - // A new client connected to the server, create and - // send all clients the updated channel list (the list has to - // be created after the received data has to be put to the - // channel first so that this channel is marked as connected) + // A new client connected to the server, the channel list + // at all clients have to be updated. This is done by sending + // a channel name request to the client which causes a channel + // name message to be transmitted to the server. If the server + // receives this message, the channel list will be automatically + // updated (implicitely). + // To make sure the protocol message is transmitted, the channel + // first has to be marked as connected. // // Usually it is not required to send the channel list to the // client currently connecting since it automatically requests @@ -716,15 +715,8 @@ bAudioOK = true; // in case the client thinks he is still connected but the server // was restartet, it is important that we send the channel list // at this place. - - -// TODO this does not work somehow (another problem: the channel name -// is not yet received from the new client) -// possible solution: create (new) request channel name message, if this one -// is received, the channel list for all clients are automatically sent -// by the server - - CreateAndSendChanListForAllConChannels(); + vecChannels[iCurChanID].ResetTimeOutCounter(); + vecChannels[iCurChanID].CreateReqChanNameMes(); } } Mutex.unlock();