Hi everyone,

I didn't success in stopping the nua stack.

Here is my client code :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <libxml/parser.h>

#include <sofia-sip/nua.h>

#include "constants.h"
#include "macros.h"
#include "xml_parser.h"

/*******************************/
/* Variables declaration       */
/*******************************/

/* application context information structure */
typedef struct application
{
  su_home_t home[1];  /* memory home */
  su_root_t *root;     /* root object */
  nua_t *nua;      /* NUA stack object */
  nua_handle_t *handle;
} application;

/* Application context structure */
application appl[1];

/*******************************/
/* Functions declaration       */
/*******************************/
static void eventCallBack(nua_event_t event,
              int status,
              char const *phrase,
              nua_t *nua,
              nua_magic_t *magic,
              nua_handle_t *nh,
              nua_hmagic_t *hmagic,
              sip_t const *sip,
              tagi_t tags[]);
static void sendMessage(const char *dest,
            const char *content);

/*******************************/
/* Main function               */
/*******************************/
int main(int argc, char **argv){
  char *ccpp = NULL;
  printDebug("ccpp : %s\n", (ccpp=createXMLCCPP()));

  sendMessage("sip:[EMAIL PROTECTED]:1234",
          ccpp);

  xmlFree((xmlChar *)ccpp);

  return EXIT_SUCCESS;
}

/*******************************/
/* Implementation of functions */
/*******************************/

/* This callback will be called by SIP stack to
 * process incoming events
 */
void eventCallBack(nua_event_t event,
              int status,
              char const *phrase,
              nua_t *nua,
              nua_magic_t *magic,
              nua_handle_t *nh,
              nua_hmagic_t *hmagic,
              sip_t const *sip,
              tagi_t tags[])
{
  printDebug("%s received MESSAGE: %03d %s\n", __FILE__, status, phrase);
 
  if(sip)
    {
      printDebug("From: %s%s" URL_PRINT_FORMAT "\n",
         sip->sip_from->a_display ? sip->sip_from->a_display : "",
         sip->sip_from->a_display ? " " : "",
         URL_PRINT_ARGS(sip->sip_from->a_url));
    }
 
  if(sip && sip->sip_subject)
    {
      printDebug("Subject: %s\n", sip->sip_subject->g_value);
    }
 
  if(sip && sip->sip_content_type)
    {
      printDebug("Content-type: %s\n", sip->sip_content_type->c_type);
    }
 
  if(sip && sip->sip_payload)
    {
      printDebug("Content: %s\n", sip->sip_payload->pl_data);
      /*fwrite(sip->sip_payload->pl_data, sip->sip_payload->pl_len, 1, 
stdout);
    fputs("\n", stdout);*/
     
    }

  /* if(sip->sip_payload && strcmp(sip->sip_payload->pl_data, TEARDOWN) 
== 0)
    {
      su_root_break(root);
      }*/

  if (status == STATUS_OK) {
    printDebug("end\n");
    /*su_root_break(appl->root); ************************************* I 
would like to stop here */
    return;
  }
}

void sendMessage(const char *dest,
         const char *content)
{
  nua_handle_t *handle;
  char buff[BUFFER_SIZE];

  /* initialize Sofia-SIP library and create event loop */ 
  su_init();

  /* initialize memory handling */
  su_home_init(appl->home);

  /* initialize root object */
  appl->root = su_root_create(appl);
 
  if (appl->root != NULL)
    {
      /* create a user agent instance. Caller and callee should bind to 
different
       * address to avoid conflicts. The stack will call the 
'eventCallBack()'
       * callback when events such as succesful registration to network,
       * an incoming call, etc, occur.
       */
      appl->nua = nua_create(appl->root, /* Event loop */
                 eventCallBack, /* Callback for processing events */
                 appl, /* Additional data to pass to callback */
                 NUTAG_URL("sip:0.0.0.0:2345;transport=tcp"), /* Address 
to bind to */
                 TAG_END()); /* Last tag should always finish the 
sequence */
      if (appl->nua != NULL)
    {
      /* set necessary parameters */
      nua_set_params(appl->nua,
             /* tags as necessary ... */
             TAG_NULL());

      /* send the informations */
      appl->handle = nua_handle(appl->nua, NULL, SIPTAG_TO_STR(dest), 
TAG_END());
     
      nua_message(appl->handle,
              SIPTAG_CONTENT_TYPE_STR("application/XML"),
              SIPTAG_PAYLOAD_STR(content),
              TAG_END());
     
      nua_handle_destroy(appl->handle);

      /* enter main loop for processing of messages */
      su_root_run(appl->root);
     
      /* destroy NUA stack */
      nua_destroy(appl->nua);
    }
     
      /* deinit root object */
      su_root_destroy(appl->root);
      appl->root = NULL;
    }
 
  /* deinitialize memory handling */
  su_home_deinit(appl->home);
 
  /* deinitialize system utilities */
  su_deinit();
}


I would like it to send a message with XML content and stop the client 
but I got this message :
nua_destroy(0x80c87f0): FATAL: nua_shutdown not completed
client: nua.c:235: nua_destroy: Assertion `nua->nua_shutdown' failed.
Aborted

Can anyone help me ?

Rémi

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to