Example #1
0
int OSGScaleViewer::run()
{
    // 1. connect to server
    eq::ServerPtr server = new eq::Server();
    if( !connectServer( server ))
    {
        EQERROR << "Can't open server" << std::endl;
        return EXIT_FAILURE;
    }

    // 2. choose config
    eq::ConfigParams configParams;
    Config* config = static_cast<Config*>( server->chooseConfig( configParams));

    if( !config )
    {
        EQERROR << "No matching config on server" << std::endl;
        disconnectServer( server );
        return EXIT_FAILURE;
    }

    config->setInitData( _initData );
    if( !config->init( ))
    {
        server->releaseConfig( config );
        disconnectServer( server );
        return EXIT_FAILURE;
    }
    else if( config->getError( ))
        EQWARN << "Error during initialization: " << config->getError()
               << std::endl;

    // 4. run main loop
    while( config->isRunning( ))
    {
        config->startFrame();
        config->finishFrame();
    }
    config->finishAllFrames();

    // 5. exit config
    config->exit();

    // 6. cleanup and exit
    server->releaseConfig( config );
    if( !disconnectServer( server ))
        EQERROR << "Client::disconnectServer failed" << std::endl;

    server = 0;

    return EXIT_SUCCESS;
}
void MainWindow::changeServerStatus(bool s)
{
    if(s)
        connectServer();
    else
        disconnectServer();
}
Example #3
0
IndiGui::~IndiGui()
{
    ready = false;   
    disconnectServer();
    ptrHash::iterator itdev;
    if (!devlist.empty()) {
    for( itdev = devlist.begin(); itdev !=devlist.end(); ++itdev )
    {
	IndiDev *indiDev = (IndiDev *) itdev->second;
	if (indiDev) {
	   ptrHash::iterator itprop;
	   for( itprop =indiDev->properties.begin(); itprop !=indiDev->properties.end(); ++itprop )
	    {
	       IndiProp *indiProp = (IndiProp *) itprop->second;
	       indiProp->ctrl.clear();
	       indiProp->entry.clear();
	       delete indiProp;
	    }
	    indiDev->properties.clear();
	    indiDev->groups.clear();
	    delete indiDev;
	}
    }
    } 
}     
Example #4
0
bool Camera_INDIClass::Disconnect()
{
    // Disconnect from server
    if (disconnectServer()) {
        return false;
    }
    else return true;
}
Example #5
0
bool Adafruit_MQTT::disconnect() {

  // Construct and send disconnect packet.
  uint8_t len = disconnectPacket(buffer);
  if (! sendPacket(buffer, len))
    DEBUG_PRINTLN(F("Unable to send disconnect packet"));

  return disconnectServer();

}
Example #6
0
/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
	Function	:disconnectSSLServer
	Input		:struct ssl_session *session
				 < session of ssl >
	Output		:struct ssl_session *session
				 < opened session >
	Return		:void
	Description	:close socket
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
int disconnectSSLServer( struct ssl_session *session )
{
	if( session->connect )
	{
		logMessage( "disconnect ssl server\n" );
		disconnectServer( session->socket );
		session->connect = false;
	}

	return( 0 );
}
Example #7
0
void Client::releaseConfig(Config* config)
{
    _impl->server->releaseConfig(config);
    if (!disconnectServer(_impl->server))
        LBERROR << "Client::disconnectServer failed" << std::endl;
    _impl->server = 0;
    exitLocal();

    LBASSERTINFO(getRefCount() == 1, "Client still referenced by "
                                         << getRefCount() - 1);
}
Example #8
0
bool ScopeINDI::Disconnect() 
{
    // Disconnect from server
    if (disconnectServer()){
       if (ready) {
	  ready = false;
	  Scope::Disconnect();
       }
       return false;
    }
    else return true;
}
Example #9
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindowClass)
{
    ui->setupUi(this);
    socket = new JagunKET(this);
    connected = false;
    connect(ui->btnConexao,SIGNAL(clicked()),this,SLOT(controlConnection()));
    connect(socket,SIGNAL(connected()),this,SLOT(connectedServer()));
    connect(socket,SIGNAL(disconnected()),this,SLOT(disconnectServer()));
    connect(socket,SIGNAL(sentData()),this,SLOT(confirmSend()));
    connect(ui->btnEnviar,SIGNAL(clicked()),this,SLOT(sendData()));
}
Example #10
0
/*!
 * Disconnects all clients, or disconnects from the server.
 */
void QxtRPCService::disconnectAll()
{
    if(isClient()) 
        disconnectServer();

    if(isServer()) {
        QList<quint64> clientIDs = clients();
        foreach(quint64 id, clientIDs) {
            // Disconnect from each client in turn.
            disconnectClient(id);
        }
    }
Example #11
0
/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
	Function	:reopenSSLSession
	Input		:struct ssl_session *session
				 < session of ssl >
	Output		:void
	Return		:int
				 < status >
	Description	:reopen a ssl session
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
int reopenSSLSession( struct ssl_session *session )
{
	if( session->ssl_handle )
	{
		//SSL_clear( session->ssl_handle );
		//SSL_free( session->ssl_handle );
	}

	if( session->ssl_context )
	{
		//SSL_CTX_free( session->ssl_context );
	}

	if( session->connect )
	{
		logMessage( "disconnect \n" );
		disconnectServer( session->socket );
		session->connect = false;
	}

	if( ( session->socket = reconnectServer( session->socket ) ) < 0 )
	{
		logMessage( "reconnect error (%d)\n", session->socket );
		return( -1 );
	}

	session->connect = true;

	/* ------------------------------------------------------------------------ */
	/* set fd																	*/
	/* ------------------------------------------------------------------------ */
	if( !SSL_set_fd( session->ssl_handle, session->socket ) )
	{
		logMessage( "cannot set socket fd to ssl\n" );
		return( -1 );
	}

	/* ------------------------------------------------------------------------ */
	/* connect ssl																*/
	/* ------------------------------------------------------------------------ */
	if( SSL_connect( session->ssl_handle ) != 1 )
	{
		logMessage( "cannot connect ssl\n" );
		return( -1 );
	}
	
	return( 0 );
}
Example #12
0
int EqPly::run()
{
    // 1. connect to server
    eq::ServerPtr server = new eq::Server;
    if( !connectServer( server ))
    {
        LBERROR << "Can't open server" << std::endl;
        return EXIT_FAILURE;
    }

    // 2. choose config
    eq::fabric::ConfigParams configParams;
    Config* config = static_cast<Config*>(server->chooseConfig( configParams ));

    if( !config )
    {
        LBERROR << "No matching config on server" << std::endl;
        disconnectServer( server );
        return EXIT_FAILURE;
    }

    // 3. init config
    lunchbox::Clock clock;

    config->setInitData( _initData );
    if( !config->init( ))
    {
        LBWARN << "Error during initialization: " << config->getError()
               << std::endl;
        server->releaseConfig( config );
        disconnectServer( server );
        return EXIT_FAILURE;
    }
    if( config->getError( ))
        LBWARN << "Error during initialization: " << config->getError()
               << std::endl;

    LBLOG( LOG_STATS ) << "Config init took " << clock.getTimef() << " ms"
                       << std::endl;

    // 4. run main loop
    uint32_t maxFrames = _initData.getMaxFrames();
    int lastFrame = 0;

    clock.reset();
    while( config->isRunning( ) && maxFrames-- )
    {
        config->startFrame();
        if( config->getError( ))
            LBWARN << "Error during frame start: " << config->getError()
                   << std::endl;
        config->finishFrame();

        if( config->getAnimationFrame() == 1 )
        {
            const float time = clock.resetTimef();
            const size_t nFrames = config->getFinishedFrame() - lastFrame;
            lastFrame = config->getFinishedFrame();

            LBLOG( LOG_STATS ) << time << " ms for " << nFrames << " frames @ "
                               << ( nFrames / time * 1000.f) << " FPS)"
                               << std::endl;
        }

        while( !config->needRedraw( )) // wait for an event requiring redraw
        {
            if( hasCommands( )) // execute non-critical pending commands
            {
                processCommand();
                config->handleEvents(); // non-blocking
            }
            else  // no pending commands, block on user event
            {
                const eq::EventICommand& event = config->getNextEvent();
                if( !config->handleEvent( event ))
                    LBVERB << "Unhandled " << event << std::endl;
            }
        }
        config->handleEvents(); // process all pending events
    }
    const uint32_t frame = config->finishAllFrames();
    const float time = clock.resetTimef();
    const size_t nFrames = frame - lastFrame;
    LBLOG( LOG_STATS ) << time << " ms for " << nFrames << " frames @ "
                       << ( nFrames / time * 1000.f) << " FPS)" << std::endl;

    // 5. exit config
    clock.reset();
    config->exit();
    LBLOG( LOG_STATS ) << "Exit took " << clock.getTimef() << " ms" <<std::endl;

    // 6. cleanup and exit
    server->releaseConfig( config );
    if( !disconnectServer( server ))
        LBERROR << "Client::disconnectServer failed" << std::endl;

    return EXIT_SUCCESS;
}
Example #13
0
int Client::run( const int argc, char** argv )
{
    // 0. Init local client
    if( !initLocal( argc, argv ))
    {
        LBERROR << "Can't init client" << std::endl;
        return EXIT_FAILURE;
    }

    // 1. connect to server
    eq::ServerPtr server = new eq::Server;
    if( !connectServer( server ))
    {
        LBERROR << "Can't open server" << std::endl;
        exitLocal();
        return EXIT_FAILURE;
    }

    // 2. choose config
    eq::fabric::ConfigParams configParams;

    Config* config = static_cast< Config * >(
        server->chooseConfig( configParams ));
    if( !config )
    {
        LBERROR << "No matching config on server" << std::endl;
        disconnectServer( server );
        exitLocal();
        return EXIT_FAILURE;
    }

    FrameData& frameData = config->getFrameData();
    frameData.setup( _impl->_applicationParameters, _impl->_rendererParameters );
    frameData.getVolumeSettings()->setURI( _impl->_applicationParameters.dataFileName);

    // 3. init config
    lunchbox::Clock clock;
    if( !config->init( argc, argv ))
    {
        server->releaseConfig( config );
        disconnectServer( server );
        exitLocal();
        return EXIT_FAILURE;
    }
    LBLOG( LOG_STATS ) << "Config init took " << clock.getTimef() << " ms"
                       << std::endl;

    // 4. run main loop
    uint32_t maxFrames = _impl->_applicationParameters.maxFrames;
    frameData.getCameraSettings()->setDefaultCameraPosition(
        _impl->_applicationParameters.cameraPosition );
    frameData.getCameraSettings()->setDefaultCameraLookAt(
        _impl->_applicationParameters.cameraLookAt );

    clock.reset();
    while( config->isRunning() && maxFrames-- )
    {
        if( !config->frame()) // If not valid, reset maxFrames
            maxFrames++;

        if( _impl->_idleFunc )
            _impl->_idleFunc(); // order is important to latency

        while( !config->needRedraw( )) // wait for an event requiring redraw
        {
            if( hasCommands( )) // execute non-critical pending commands
            {
                processCommand();
                config->handleEvents(); // non-blocking
            }
            else  // no pending commands, block on user event
            {
                // Poll ZeroEq subscribers at least every 100 ms in handleEvents
                const eq::EventICommand& event = config->getNextEvent( 100 );
                if( event.isValid( ))
                    config->handleEvent( event );
                config->handleEvents(); // non-blocking
            }
        }
        config->handleEvents(); // process all pending events
    }

    const uint32_t frame = config->finishAllFrames();
    const float    time  = clock.getTimef();
    LBLOG( LOG_STATS ) << "Rendering took " << time << " ms (" << frame
                       << " frames @ " << ( frame / time * 1000.f) << " FPS)"
                       << std::endl;

    // 5. exit config
    clock.reset();
    config->exit();
    LBLOG( LOG_STATS ) << "Exit took " << clock.getTimef() << " ms" <<std::endl;

    // 6. cleanup and exit
    server->releaseConfig( config );
    if( !disconnectServer( server ))
        LBERROR << "Client::disconnectServer failed" << std::endl;
    server = 0;
    exitLocal();

    return EXIT_SUCCESS;
}
Example #14
0
void INDIConfig::Disconnect() 
{
   disconnectServer();
   connect_status->SetLabel(_T("Disconnected"));
}
Example #15
0
INDIConfig::~INDIConfig()
{
    disconnectServer();    
}
Example #16
0
RemoteHost::~RemoteHost()
{ 
   disconnectServer();
}
Example #17
0
int EVolve::run()
{
    // 1. connect to server
    eq::ServerPtr server = new eq::Server;
    if( !connectServer( server ))
    {
        LBERROR << "Can't open server" << std::endl;
        return EXIT_FAILURE;
    }

    // 2. choose config
    eq::fabric::ConfigParams configParams;
    Config* config = static_cast<Config*>(server->chooseConfig( configParams ));

    if( !config )
    {
        LBERROR << "No matching config on server" << std::endl;
        disconnectServer( server );
        return EXIT_FAILURE;
    }

    // 3. init config
    lunchbox::Clock clock;

    config->setInitData( _initData );
    if( !config->init( ))
    {
        server->releaseConfig( config );
        disconnectServer( server );
        return EXIT_FAILURE;
    }
    else if( config->getError( ))
        LBWARN << "Error during initialization: " << config->getError()
               << std::endl;

    LBLOG( LOG_STATS ) << "Config init took " << clock.getTimef() << " ms"
                       << std::endl;

    // 4. run main loop
    uint32_t maxFrames = _initData.getMaxFrames();
    
    clock.reset();
    while( config->isRunning( ) && maxFrames-- )
    {
        config->startFrame();
        if( config->getError( ))
            LBWARN << "Error during frame start: " << config->getError()
                   << std::endl;
        config->finishFrame();
    }
    const uint32_t frame = config->finishAllFrames();
    const float    time  = clock.getTimef();
    LBLOG( LOG_STATS ) << "Rendering took " << time << " ms (" << frame
                       << " frames @ " << ( frame / time * 1000.f) << " FPS)"
                       << std::endl;

    // 5. exit config
    clock.reset();
    config->exit();
    LBLOG( LOG_STATS ) << "Exit took " << clock.getTimef() << " ms" <<std::endl;

    // 6. cleanup and exit
    server->releaseConfig( config );
    if( !disconnectServer( server ))
        LBERROR << "Client::disconnectServer failed" << std::endl;
    server = 0;

    return EXIT_SUCCESS;
}
Example #18
0
int EQEarth::run( )
{
    int ret = EXIT_FAILURE;
    eq::ServerPtr server;
    eq::fabric::ConfigParams configParams;
    Config* config = NULL;

    server = new eq::Server( );
    if( !connectServer( server ))
    {
        LBERROR << "Client::connectServer failed" << std::endl;
        goto out;
    }

    config = static_cast< Config* >( server->chooseConfig( configParams ));
    if( !config )
    {
        LBERROR << "Server::chooseConfig failed" << std::endl;
        goto out_disconnect;
    }

    config->setInitData( _initData );
    if( !config->init( ))
    {
        LBERROR << "Config::init failed" << std::endl;
        goto out_release;
    }

#if 0
    if( config->getError( ))
    {
        LBERROR << "Config::init error : " << config->getError( ) << std::endl;
        goto out_exit;
    }
#endif

    while( config->isRunning( ))
    {
        config->startFrame( );
        config->finishFrame( );
    }
    config->finishAllFrames( );

    ret = EXIT_SUCCESS;

out_exit:
    if( !config->exit( ))
        LBWARN << "Config::exit failed" << std::endl;

out_release:
    server->releaseConfig( config );

out_disconnect:
    if( !disconnectServer( server ))
        LBWARN << "Client::disconnectServer failed" << std::endl;

out:
    server = 0;

    return ret;
}
Example #19
0
int VolVis::run()
{
    // 1. connect to server
    eq::ServerPtr server = new eq::Server;
    if( !connectServer( server ))
    {
        LBERROR << "Can't open server" << std::endl;
        return EXIT_FAILURE;
    }

    // 2. choose config
    eq::fabric::ConfigParams configParams;
    Config* config = static_cast<Config*>(server->chooseConfig( configParams ));

    if( !config )
    {
        LBERROR << "No matching config on server" << std::endl;
        disconnectServer( server );
        return EXIT_FAILURE;
    }

    GUIDock guiDock;
    if( !guiDock.init( config ))
    {
        LBERROR << "Can't intialize GUI handler" << std::endl;

        config->exit();
        server->releaseConfig( config );
        if( !disconnectServer( server ))
            LBERROR << "Client::disconnectServer failed" << std::endl;
        server = 0;

        return EXIT_FAILURE;
    }

    // 3. init config
    lunchbox::Clock clock;

    config->setInitData( _initData );
    if( !config->init( eq::uint128_t( )))
    {
        server->releaseConfig( config );
        disconnectServer( server );
        return EXIT_FAILURE;
    }

    LBLOG( LOG_STATS ) << "Config init took " << clock.getTimef() << " ms"
                       << std::endl;

    // 4. run main loop
    uint32_t maxFrames = _initData.getMaxFrames();

    clock.reset();
    while( config->isRunning( ) && maxFrames-- )
    {
        config->startFrame( eq::uint128_t( ));
        config->finishFrame();
    }
    const uint32_t frame = config->finishAllFrames();
    const float    time  = clock.getTimef();
    LBLOG( LOG_STATS ) << "Rendering took " << time << " ms (" << frame
                       << " frames @ " << ( frame / time * 1000.f) << " FPS)"
                       << std::endl;


    if( _initData.dumpStatistics() )
        util::StatLogger::instance().printStats();

    // 5. exit config
    clock.reset();
    config->exit();
    LBLOG( LOG_STATS ) << "Exit took " << clock.getTimef() << " ms" <<std::endl;

    // 6. cleanup and exit
    server->releaseConfig( config );
    if( !disconnectServer( server ))
        LBERROR << "Client::disconnectServer failed" << std::endl;
    server = 0;

    return EXIT_SUCCESS;
}
Example #20
0
Camera_INDIClass::~Camera_INDIClass()
{
    disconnectServer();
}