Ejemplo n.º 1
0
void NamedEventTest::testNamedEvent()
{
	Thread thr1;
	TestEvent te;
	thr1.start(te);
	Timestamp now;
	Thread::sleep(2000);
	testEvent.set();
	thr1.join();
	assert (te.timestamp() > now);

	Thread thr2;
	thr2.start(te);
	now.update();
	Thread::sleep(2000);
	testEvent.set();
	thr2.join();
	assert (te.timestamp() > now);
}
Ejemplo n.º 2
0
void RTMFPServerEdge::run() {
	_serverSocket.connect(_serverAddress);
	sockets.add(_serverSocket,*this);

	_serverConnection.setEndPoint(_serverSocket,_serverAddress);

	NOTE("Wait RTMFP server %s successful connection...",_serverAddress.toString().c_str());

	Timestamp connectAttemptTime;	
	_serverConnection.connect(_publicAddress);

	bool terminate=false;

	while(running()) {
		if(!sockets.process(_timeout)) {
			if(connectAttemptTime.isElapsed(6000000)) {
				_serverConnection.connect(_publicAddress);
				connectAttemptTime.update();
			}
			continue;
		}
		if(_serverConnection.connected()) {
			NOTE("RTMFP server %s successful connection",_serverAddress.toString().c_str());
			RTMFPServer::run();
			_serverConnection.clear();
			if(_serverConnection.connected()) {
				// Exception in RTMFPServer::run OR a volontary stop
				_serverConnection.setEndPoint(_serverSocket,_serverAddress);
				_serverConnection.disconnect();
				break; 
			}
			NOTE("RTMFP server %s connection lost",_serverAddress.toString().c_str());
		}
	}
	_sendingEngine.clear();
	sockets.remove(_serverSocket);
	_serverSocket.close();
}