void NotificationManager::startNotifyThread(){
    if(!isSokcetInited) {
        mListener = NULL;
        registerListener(new NuCommandListener());
        startListener();
        isSokcetInited = true;
    }
}
Пример #2
0
void ClientSocket :: loadChatHistory() {
    std::string mensaje;

    Logger::log("CLIENT", "Se inicia el listener" , DEBUG);
    startListener();

    Logger::log("CLIENT", "Se carga el historial del chat" , DEBUG);
    mensaje = std::string(SEPARATOR) + ": " + nickname;
    enviar ( static_cast<const void*>(mensaje.c_str()),mensaje.size() );
}
Пример #3
0
void start()
{
	createSocket();

	bindSocket();

	startListener();

	while ( 1 )
	{
		acceptConnection();
	}
}
Пример #4
0
UDP::UDP() :
    port(1926),
    timeout(2000)
{
    isListening = false;
    Logger::Instance()->add("Initializing UDP");

    // let's restart the listener every 15 seconds as it seems that it stops working after a certain amount of time or received data
    QTimer *timer = new QTimer();
    connect(timer, SIGNAL(timeout()), this, SLOT(restartListener()));
    timer->start(15000);

    startListener(true);
}
Пример #5
0
void SkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
	switch (type) {
	case SP_ANIMATION_START:
		if (startListener) startListener(trackIndex);
		break;
	case SP_ANIMATION_END:
		if (endListener) endListener(trackIndex);
		break;
	case SP_ANIMATION_COMPLETE:
		if (completeListener) completeListener(trackIndex, loopCount);
		break;
	case SP_ANIMATION_EVENT:
		if (eventListener) eventListener(trackIndex, event);
		break;
	}
}
Пример #6
0
ModPlay::ModPlay(const void* data, size_t size) : hWaveOut(NULL), hThread(NULL), hEventDone(NULL), currentBuffer(0), stopped(false)
{
	initPlayer();
	if(loadData(data, size))
	{
		if(startListener() && initDevice())
		{
			for(int i = 0; i < BUFFERS; i++)
			{
				memset(&headers[i], 0, sizeof(WAVEHDR));
				headers[i].lpData = reinterpret_cast<LPSTR>(buffers[i]);
				headers[i].dwBufferLength = BUFSIZE;
				fillBuffer(i);
			}
		}
	}
}
Пример #7
0
int main(int argc, char *argv[]) {
    QApplication a(argc, argv);

    //listenStatus = 1;
    //if (localPortIsOpen(QHostAddress::LocalHost,9250) || localPortIsOpen(QHostAddress::LocalHost,9251)) torStatus = -1;
    //if (localPortIsOpen(QHostAddress::Any, 445)) listenStatus = 0;

    //Database::db = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE"));
    //Database::db->setDatabaseName("db.sqlite");
    //Database::setDB();

    QThread *thread = new QThread;
    Daemon *Tor = new Daemon;
    Tor->moveToThread(thread);
    QObject::connect(thread, SIGNAL(started()), Tor, SLOT(startTor()));
    QObject::connect(Tor, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection);
    QObject::connect(thread, SIGNAL(finished()), Tor, SLOT(deleteLater()));
    QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();

    QThread *thread2 = new QThread;
    Daemon *daemon = new Daemon;
    daemon->moveToThread(thread2);
    QObject::connect(thread2, SIGNAL(started()), daemon, SLOT(startListener()));
    QObject::connect(daemon, SIGNAL(ListenerStarted()), daemon, SLOT(init()));
    QObject::connect(daemon, SIGNAL(finished()), thread2, SLOT(quit()), Qt::DirectConnection);
    QObject::connect(thread2, SIGNAL(finished()), daemon, SLOT(deleteLater()));
    QObject::connect(thread2, SIGNAL(finished()), thread2, SLOT(deleteLater()));
    thread2->start();

    QThread *thread3 = new QThread;
    JobsManager *jobsmanager = new JobsManager;
    QObject::connect(thread3, SIGNAL(started()), jobsmanager, SLOT(worker()));
    jobsmanager->moveToThread(thread3);
    thread3->start();

    Dialog *dialog = new Dialog();
    dialog->show();
    QTimer::singleShot(4000, dialog, SLOT(hide()));
    Systray *systray = new Systray();
    QObject::connect(systray, SIGNAL(exit()), &a, SLOT(quit()));
    QObject::connect(jobsmanager, SIGNAL(update()), systray, SLOT(update()));
    return a.exec();
}
Пример #8
0
void UDP::restartListener()
{
    stopListener();
    startListener(false);
}
int SocketListener::startListener() {
    return startListener(4);
}
Пример #10
0
void GDMManager::startAnnouncing()
{
  startListener();
}
Пример #11
0
/*
 * This method allows both the host name and port number to
 * be specified for making the connection. This is used by
 * the other connection mathods as it is the most general
 * form of the function.
 */
bool CKIRCProtocol::connect( const CKString & aHost, int aPort )
{
	bool		error = false;

	// first, see if we are already connected to some host
	if (!error) {
		if (isConnected() && ((mHostname != aHost) || (mPort != aPort))) {
			error = true;
			std::ostringstream	msg;
			msg << "CKIRCProtocol::connect(const CKString & , int) - there's an "
				"established connection to the server on " << mHostname << ":" <<
				mPort << " and that connection needs to be closed before we can "
				"connect to another host and/or port. Please call disconnect().";
			throw CKException(__FILE__, __LINE__, msg.str());
		}
	}

	// now, tell the connection object to connect to the right host and port
	if (!error) {
		// lock up the port
		CKStackLocker	lockem(&mCommPortMutex);
		// try to make the connection
		if (!mCommPort.connect(aHost, aPort)) {
			error = true;
			std::ostringstream	msg;
			msg << "CKIRCProtocol::connect(const CKString & , int) - the "
				"connection to the server on " << aHost << ":" <<
				aPort << " could not be created and that's a serious problem. "
				"Please make sure that there's an IRC server on that box.";
			throw CKException(__FILE__, __LINE__, msg.str());
		} else {
			// save the host and port for later
			mHostname = aHost;
			mPort = aPort;
			/*
			 * The connection was good, so let's set the read timeout to
			 * the default value which is understandably short given the
			 * quasi-polling nature of the IRC Listener
			 */
			mCommPort.setReadTimeout(DEFAULT_IRC_READ_TIMEOUT);
		}
	}

	// if we're good, then save all the parts and start the listener
	if (!error) {
		// start the listener so it can monitor incoming traffic
		if (mListener == NULL) {
			// create a listener for this guy
			mListener = new CKIRCProtocolListener(this);
			if (mListener == NULL) {
				error = true;
				std::ostringstream	msg;
				msg << "CKIRCProtocol::connect(const CKString & , int) - the "
					"Listener for this instance could not be created. This is a "
					"serious allocation problem.";
				throw CKException(__FILE__, __LINE__, msg.str());
			}
		}
		// ...now start it - if it needs to be started
		startListener();
	}

	return !error;
}