Пример #1
0
/**
 * @brief    Stop the internal TMLCoreListener.
 */
int TMLCoreListener::TMLCoreListener_Stop() 
{
  int iRet = TML_SUCCESS;

  if (m_hValidListenerThread)
  {
/*
  if (NULL != m_ctx){
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // end vortex function / this will unblock the vortex_listener_wait(..) in the LisenerThread to end the thread:
    m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "StopVortexListenerThread", "Vortex CMD", "vortex_exit_ctx");
    vortex_exit_ctx (m_ctx, axl_true);
    m_ctx = NULL;
  }
*/
    m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "TMLCoreListener_Stop", "Vortex CMD", "vortex_listener_set_on_connection_accepted");
    vortex_listener_set_on_connection_accepted (m_ctx, NULL, NULL);

    /////////////////////////////////////
    // Destroy allocated handle:
    m_hValidListenerThread = false;
  }
  else{
     iRet = TML_ERR_LISTENER_NOT_INITIALIZED;
  }
  return iRet;
}
int  main (int  argc, char ** argv)
{

    /* create the context */
    ctx = vortex_ctx_new ();

    vortex_thread_pool_set_num (1);

    /* init vortex library */
    if (! vortex_init_ctx (ctx)) {
        /* unable to init context */
        vortex_ctx_free (ctx);

        return -1;
    } /* end if */

    vortex_thread_pool_setup2 (ctx, 40, 1, 1, 1, 4, axl_true, axl_true);

    /* register a profile */
    vortex_profiles_register (ctx, PLAIN_PROFILE,
                              start_channel, NULL,
                              close_channel, NULL,
                              frame_received, NULL);

    /* create a vortex server */
    vortex_listener_new (ctx, "0.0.0.0", "44000", NULL, NULL);

    /* configure connection notification */
    vortex_listener_set_on_connection_accepted (ctx, on_accepted, NULL);

    /* wait for listeners (until vortex_exit is called) */
    vortex_listener_wait (ctx);

    /* end vortex function */
    vortex_exit_ctx (ctx, axl_true);

    return 0;
}