コード例 #1
0
int main (int argc, char ** argv) 
{
	VortexCtx * ctx;

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

	vortex_log_enable (ctx, axl_true);
	vortex_color_log_enable (ctx, axl_true);

	signal (SIGSEGV, __sigsegv_handler);
	signal (SIGABRT, __sigsegv_handler);

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		printf ("Failed to start vortex library..\n");
		return -1;
	}

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

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

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

	/* terminate library execution */
	vortex_exit_ctx (ctx, axl_true);

	return 0;
}
コード例 #2
0
int  main (int  argc, char ** argv) 
{

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

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		/* unable to init context */
		vortex_ctx_free (ctx);
		return -1;
	} /* end if */

	/* register a profile */
	vortex_profiles_register (ctx, PLAIN_PROFILE, 
				  start_channel, NULL, 
				  close_channel, NULL,
				  frame_received, NULL);
	
	vortex_greetings_set_features (ctx, "enable-tls");
	vortex_greetings_set_localize (ctx, "es-ES");

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

	/* wait for listeners (until vortex_exit is called) */
	vortex_listener_wait (ctx);
	
	/* end vortex function */
	vortex_exit_ctx (ctx, axl_true);

	return 0;
}
コード例 #3
0
int  main (int  argc, char ** argv) 
{

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

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		/* unable to init context */
		vortex_ctx_free (ctx);
		return -1;
	} /* end if */

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

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

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

	/* do not call vortex_exit here if you define an on ready
	 * function which actually ends the execution */

	return 0;
}
コード例 #4
0
ファイル: mod-test.c プロジェクト: ASPLes/turbulence
/** 
 * @brief Init function, perform all the necessary code to register
 * profiles, configure Vortex, and any other init task. The function
 * must return true to signal that the module was properly initialized
 * Otherwise, false must be returned.
 */
static int  test_init (TurbulenceCtx * _ctx)
{
	/* configure the module */
	TBC_MOD_PREPARE (_ctx);

	/* using TBC_VORTEX_CTX allows to get the vortex context from
	 * the turbulence ctx */
	
	msg ("Turbulence BEEP server, test module: init");

	/* register all profiles without handlers: testing purposes */
	vortex_profiles_register (TBC_VORTEX_CTX (ctx),
				  MOD_TEST_URI1,
				  NULL, NULL,
				  NULL, NULL,
				  NULL, NULL);

	vortex_profiles_register (TBC_VORTEX_CTX (ctx),
				  MOD_TEST_URI2,
				  NULL, NULL,
				  NULL, NULL,
				  NULL, NULL);

	vortex_profiles_register (TBC_VORTEX_CTX (ctx),
				  MOD_TEST_URI3,
				  NULL, NULL,
				  NULL, NULL,
				  NULL, NULL);

	vortex_profiles_register (TBC_VORTEX_CTX (ctx),
				  MOD_TEST_URI4,
				  NULL, NULL,
				  NULL, NULL,
				  NULL, NULL);

	return axl_true;
}
コード例 #5
0
ファイル: mod_test_11.c プロジェクト: ASPLes/turbulence
/* mod_test_11 ppath-selected handler */
static axl_bool mod_test_11_ppath_selected (TurbulenceCtx * _ctx, TurbulencePPathDef * ppath_selected, VortexConnection * conn) {

	/* mutex lock */
	vortex_mutex_lock (&mutex);
	
	/* unlock mutex */
	vortex_mutex_unlock (&mutex);

	msg ("Test 11: received profile path selected %s, connection id %d", 
	     turbulence_ppath_get_name (ppath_selected), vortex_connection_get_id (conn));

	/* register a profile at this point */
	vortex_profiles_register (TBC_VORTEX_CTX (ctx), "urn:aspl.es:beep:profiles:reg-test:profile-11",
				  NULL, NULL, NULL, NULL, mod_test_11_frame_received, NULL);

	/* notification ok */
	return true;
} /* end mod_test_11_ppath_selected */
コード例 #6
0
ファイル: tmlCoreListener.cpp プロジェクト: tml21/libtml-c
/**
 * @brief    Register a profile
 */
int TMLCoreListener::TMLCoreListener_RegisterProfile(const char* profile) 
{
  int iRet = TML_SUCCESS;
  if (NULL != m_ctx){
        bool bRegisterProfile = false;
        bool bRegisterCB = false;
        m_pHandler->tmlProfileRegister(profile, true, (void*)listenerFrameReceivedCallback, &m_callbackData, &bRegisterProfile, &bRegisterCB);

        int bOk;
        if (bRegisterProfile){
          m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "TMLCoreListener_RegisterProfile", "Vortex CMD", "vortex_profiles_register");
          bOk = vortex_profiles_register (m_ctx, profile, 
                                          NULL, NULL,
                                          NULL, NULL,
                                          NULL, NULL);

          if (axl_false == bOk){
            m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "Profile registration of profile", profile, " failed !");
            iRet = TML_ERR_LISTENER_COMMUNICATION;
          }
          else{
            m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "Profile registration of profile", profile, " succeeded");
          }
        }
        if (TML_SUCCESS == iRet){
          if (bRegisterCB){
            m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "TMLCoreListener_RegisterProfile", "Vortex CMD", "vortex_profiles_set_received_handler");
            bOk = vortex_profiles_set_received_handler (m_ctx, profile, 
                                          listenerFrameReceivedCallback, &m_callbackData);
            if (axl_false == bOk){
              iRet = TML_ERR_LISTENER_COMMUNICATION;
            }
          }
        }
  }
  else
  {
    iRet = TML_ERR_LISTENER_NOT_INITIALIZED;
  }
  return iRet;
}
コード例 #7
0
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;
}
コード例 #8
0
int main (int argc, char ** argv) {

	/* the all frames received queue */
	VortexAsyncQueue * queue;
	VortexFrame      * frame;
	VortexChannel    * channel;

	/* count */
	int             iterator = 0;
	
	/* create the context */
	ctx = vortex_ctx_new ();

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		/* unable to init context */
		vortex_ctx_free (ctx);
		return -1;
	} /* end if */
	
	/* create the queue */
	queue = vortex_async_queue_new ();

	/* register a profile */
	vortex_profiles_register (ctx, PROFILE_URI,
				  /* no start handler, accept all channels */
				  NULL, NULL,
				  /* no close channel, accept all
				   * channels to be closed */
				  NULL, NULL,
				  vortex_channel_queue_reply, queue);
	
	/* now create a vortex server listening on several ports */
	vortex_listener_new (ctx, "0.0.0.0", "4400", NULL, NULL);


	/* and handle all frames received */
	while (axl_true) {

		/* get the next message, blocking at this call. 
		 *
		 * NOTE: This call must be evolved to something with
		 * error handling, timeout and channel piggyback
		 * support, but, for the example will do.  */
		frame = vortex_async_queue_pop (queue);

		if (frame == NULL) {
			/* for our example, the default action is:
			 *     keep on reading!.
			 */
			continue;
		}
		printf ("Frame received, content: %s\n",
			(char*) vortex_frame_get_payload (frame));

		/* get the channel */
		channel = vortex_frame_get_channel_ref (frame);
		
		/* reply */
		vortex_channel_send_rpy (channel, 
					 vortex_frame_get_payload (frame),
					 vortex_frame_get_payload_size (frame),
					 vortex_frame_get_msgno (frame));

		/* deallocate the frame received */
		vortex_frame_free (frame);

		iterator++;

		/* close the channel */
		if (iterator == 10) {
			/* close the channel */
			if (! vortex_channel_close (channel, NULL)) {
				printf ("Unable to close the channel!\n");
			}

			printf ("Ok, channel closed\n");

			/* reset */
			iterator = 0;
			
		} /* end if */
	} /* end while */
	
	
	/* end vortex internal subsystem (if no one have done it yet!) */
	vortex_exit_ctx (ctx, axl_true);
 
	/* that's all to start BEEPing! */
	return 0;     
 }