implementation of channel name request message, required if server is restarted while client thinks it is still connected

This commit is contained in:
Volker Fischer 2009-09-17 19:15:56 +00:00
parent a8a3ebd483
commit 65d61f1c0e
10 changed files with 52 additions and 31 deletions

View File

@ -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) }" );
*/

View File

@ -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<uint8_t>& vecbyData,
bNewConnection = !IsConnected();
// reset time-out counter
iConTimeOut = iConTimeOutStartVal;
ResetTimeOutCounter();
}
Mutex.unlock();
}

View File

@ -68,6 +68,7 @@ public:
CVector<uint8_t> PrepSendPacket ( const CVector<uint8_t>& 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<CChannelShortInfo> vecChanInfo );
void NameHasChanged();
void ReqChanName();
void ChatTextReceived ( QString strChatText );
void PingReceived ( int iMs );
void ReqNetTranspProps();

View File

@ -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<CChannelShortInfo> ) ),
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
@ -92,12 +95,6 @@ void CClient::OnSendProtMessage ( CVector<uint8_t> 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

View File

@ -202,7 +202,8 @@ protected:
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize();
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
void OnReqChanName() { Channel.SetRemoteName ( strName ); }
void OnNewConnection();
void OnReceivePingMessage ( int iMs );
void OnSndCrdReinitRequest();

View File

@ -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<uint8_t>& vecData )
return false; // no error
}
void CProtocol::CreateReqChanNameMes()
{
CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_NAME, CVector<uint8_t> ( 0 ) );
}
bool CProtocol::EvaluateReqChanNameMes ( const CVector<uint8_t>& vecData )
{
// invoke message action
emit ReqChanName();
return false; // no error
}
void CProtocol::CreateChatTextMes ( const QString strChatText )
{
unsigned int iPos = 0; // init position pointer

View File

@ -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<uint8_t>& vecData );
bool EvaluateReqConnClientsList ( const CVector<uint8_t>& vecData );
bool EvaluateChanNameMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqChanNameMes ( const CVector<uint8_t>& vecData );
bool EvaluateChatTextMes ( const CVector<uint8_t>& vecData );
bool EvaluatePingMes ( const CVector<uint8_t>& vecData );
bool EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& 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 );

BIN
src/res/faderhandle.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -33,6 +33,9 @@
<file>res/VRLEDYellow.png</file>
<file>res/VRLEDYellowSmall.png</file>
</qresource>
<qresource prefix="/png/fader" >
<file>res/faderhandle.png</file>
</qresource>
<qresource prefix="/png/main" >
<file>res/gig.png</file>
<file>res/mainicon.png</file>

View File

@ -688,25 +688,24 @@ bool CServer::PutData ( const CVector<uint8_t>& 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();