pdoria
14th January 2008, 02:30
Hi All,
I recognize that this question falls pretty much into C++, but since I'm using the threaded server example to develop a server, please bare with me... ;)
As to my question:
the server class is defined as followed:
class Server : public QTcpServer
{
Q_OBJECT
public:
unsigned int nbrClients;
Server ( QObject *parent = 0 );
protected:
void incomingConnection ( int socketDescriptor );
};
in myunit.cpp the constructor:
myUnit ( int socketDescriptor, QObject *parent );
in server.cpp I initiate the object like this:
myUnit *munit = new myUnit ( socketDescriptor,this );
in myunit.cpp I have a member function that gets fired upon the socket disconnected state by this:
connect ( &tcpSocket, SIGNAL ( disconnected() ), this, SLOT ( disconnected() ) );
this is the member function:
void myUnit::disconnected()
{
//server::nbrClients--; provided for clarity of purpose... ;)
this->quit();
}
What I need is to access the nbrClients member inside this function as to decrement it upon socket disconnection...
I'll appreciate any pointers on how to do so.
Thanks in advance.
Pedro Doria Meunier.
I recognize that this question falls pretty much into C++, but since I'm using the threaded server example to develop a server, please bare with me... ;)
As to my question:
the server class is defined as followed:
class Server : public QTcpServer
{
Q_OBJECT
public:
unsigned int nbrClients;
Server ( QObject *parent = 0 );
protected:
void incomingConnection ( int socketDescriptor );
};
in myunit.cpp the constructor:
myUnit ( int socketDescriptor, QObject *parent );
in server.cpp I initiate the object like this:
myUnit *munit = new myUnit ( socketDescriptor,this );
in myunit.cpp I have a member function that gets fired upon the socket disconnected state by this:
connect ( &tcpSocket, SIGNAL ( disconnected() ), this, SLOT ( disconnected() ) );
this is the member function:
void myUnit::disconnected()
{
//server::nbrClients--; provided for clarity of purpose... ;)
this->quit();
}
What I need is to access the nbrClients member inside this function as to decrement it upon socket disconnection...
I'll appreciate any pointers on how to do so.
Thanks in advance.
Pedro Doria Meunier.