added initial code for server status file

This commit is contained in:
Volker Fischer 2008-08-08 06:28:47 +00:00
parent f425bf3d8b
commit 1cc421fc56
2 changed files with 88 additions and 1 deletions

View file

@ -28,7 +28,7 @@
/******************************************************************************\ /******************************************************************************\
* CChannelSet * * CChannelSet *
\******************************************************************************/ \******************************************************************************/
CChannelSet::CChannelSet() CChannelSet::CChannelSet() : bWriteStatusHTMLFile ( false )
{ {
// enable all channels // enable all channels
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
@ -301,6 +301,12 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
// request, only the already connected clients get the list // request, only the already connected clients get the list
// automatically, because they don't know when new clients connect // automatically, because they don't know when new clients connect
CreateAndSendChanListForAllExceptThisChan ( iCurChanID ); CreateAndSendChanListForAllExceptThisChan ( iCurChanID );
// create status HTML file if enabled
if ( bWriteStatusHTMLFile )
{
WriteHTMLChannelList();
}
} }
} }
Mutex.unlock(); Mutex.unlock();
@ -385,6 +391,12 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
{ {
// update channel list for all currently connected clients // update channel list for all currently connected clients
CreateAndSendChanListForAllConChannels(); CreateAndSendChanListForAllConChannels();
// create status HTML file if enabled
if ( bWriteStatusHTMLFile )
{
WriteHTMLChannelList();
}
} }
} }
Mutex.unlock(); // release mutex Mutex.unlock(); // release mutex
@ -422,6 +434,76 @@ void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
// TEST
void CChannelSet::WriteHTMLChannelList()
{
// create channel list
CVector<CChannelShortInfo> vecChanInfo ( CChannelSet::CreateChannelList() );
// TEST
QString strServerHTMLFileListName = "llconserverxxx.txt";
// prepare file and stream
QFile serverFileListFile ( strServerHTMLFileListName );
if ( !serverFileListFile.open ( QIODevice::WriteOnly | QIODevice::Text ) )
{
return;
}
QTextStream streamFileOut ( &serverFileListFile );
// TEST
QString strServerNameWithPort = "llcon.dyndns.org:22122";
streamFileOut << strServerNameWithPort << endl << "<ul>" << endl;
// get the number of connected clients
int iNumConnClients = 0;
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{
if ( vecChannels[i].IsConnected() )
{
iNumConnClients++;
}
}
// depending on number of connected clients write list
if ( iNumConnClients == 0 )
{
// no clients are connected -> empty server
streamFileOut << " Empty server" << endl;
}
else
{
// write entry for each connected client
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{
if ( vecChannels[i].IsConnected() )
{
streamFileOut << " <li>" << vecChannels[i].GetName() << "</li>" << endl;
}
}
}
// finish list
streamFileOut << "</ul>" << endl;
}
/******************************************************************************\ /******************************************************************************\
* CChannel * * CChannel *
\******************************************************************************/ \******************************************************************************/

View file

@ -27,6 +27,8 @@
#include <qthread.h> #include <qthread.h>
#include <qdatetime.h> #include <qdatetime.h>
#include <qfile.h>
#include <qtextstream.h>
#include "global.h" #include "global.h"
#include "buffer.h" #include "buffer.h"
#include "audiocompr.h" #include "audiocompr.h"
@ -241,12 +243,15 @@ protected:
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID ); void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
void CreateAndSendChanListForThisChan ( const int iCurChanID ); void CreateAndSendChanListForThisChan ( const int iCurChanID );
void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ); void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText );
void WriteHTMLChannelList();
/* do not use the vector class since CChannel does not have appropriate /* do not use the vector class since CChannel does not have appropriate
copy constructor/operator */ copy constructor/operator */
CChannel vecChannels[MAX_NUM_CHANNELS]; CChannel vecChannels[MAX_NUM_CHANNELS];
QMutex Mutex; QMutex Mutex;
bool bWriteStatusHTMLFile;
public slots: public slots:
// CODE TAG: MAX_NUM_CHANNELS_TAG // CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!! // make sure we have MAX_NUM_CHANNELS connections!!!