I need to know how can I send notifications back from tcpServer threads to the mainThread. I know how to send from the MainThread to them but back I'm not sure how...
I saw in tutorials that TimedNotificationQueue is a good solution together with Enqued Notifications, but can someone give me an example?
My code is like this:
I have MainThread where I have:
- Code: Select all
s = new TCPServer(&mcf, *sTh, *sSocket, ServerParams);
s->start();
mcf is the ServerConnectionFactory object which creates the threads when a new connection is created and here I also have methods that send Notifications to threads.
- Code: Select all
#include "ServerConnectionFactory.h"
ServerConnectionFactory::ServerConnectionFactory(void)
{
}
ServerConnectionFactory::~ServerConnectionFactory()
{
}
TCPServerConnection* ServerConnectionFactory::createConnection(const StreamSocket& socket)
{
return new ServerConnection(socket, _nc, &mystruct);
//return new ServerConnection(socket, _nc);
}
void ServerConnectionFactory::notifyThreads(Notification* pN) // used for notifying connected threads and send data to client. NOW use to tell thread to forcedly STOP.
{
_nc.postNotification(pN);
}
void ServerConnectionFactory::setStruct(const GlobalPass& tc)
{
mystruct = tc;
}
void ServerConnectionFactory::notifyThreadsShutDown(ShutDownThreadNotification* sd)
{
_nc.postNotification(sd);
}
It is posible to use the _nc (NotificationCenter) here to get notifications back? Or do you have any idea how can I do this?
Thank you!





