Overview
Features
Download
Documentation
Community
Add-Ons & Services

Send notifications from tcpServer clients(threads) to main

Please post support and help requests here.

Send notifications from tcpServer clients(threads) to main

Postby cosu2004 » 01 Nov 2012, 00:54

Hello guys,

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!
cosu2004
 
Posts: 14
Joined: 05 Jul 2012, 10:50

Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests

cron