Dear all,
I was trying
to use sofia_sip to write some simple codes, which is supposed to send a text
message to another client. However, when I execute, I receive an error message
saying 'nta outgoing create: invalid URI.'
Anyone can kindly give me some hints on how to fix the problem? Thanks a lot!
Best regards,
Stella
The exact output is like this:
_________________________________________________
create operation handle: OK
nta outgoing create: invalid URI
send msg: OK
entering main loop for processing of messages
Than the progam just hang there, before entering main loop
_________________________________________________
My code is something like this:
/********************************************************************************/
/* include all the header files ....*/
#define SOFSIP_USE_GLIB_EVENT_LOOP 1
void event_callback(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[]);
typedef struct cli_s {
su_home_t cli_home[1]; /* memory home */
su_root_t *cli_root; /* Pointer to application root object */
nua_t *cli_nua; /* Pointer to nua stack object */
} cli_t ;
static cli_t cli[1] = {{{{sizeof(cli)}}}};
void main()
{
sipinit();
send_message("star03", "sip:111.111.112.64")
runsipmainloop()
sipcleanup()
}
int sipinit(void)
{
/* step: initialize glib and gstreamer */
#if HAVE_GLIB
g_type_init();
#if HAVE_GST
{
guint major, minor, micro, nano;
gst_init (NULL, NULL);
gst_version (&major, &minor, µ, &nano);
g_message ("This program is linked against GStreamer %d.%d.%d\n",
major, minor, micro);
}
#endif
#endif
su_home_init(cli->cli_home);
su_init();
cli->cli_root =su_root_create(cli);
if (cli->cli_root != NULL)
{
cli->cli_nua = nua_create(cli->cli_root,
event_callback,
cli,
NUTAG_URL("sip:0.0.0.0:5060"),
TAG_END());
}
return 0;
}
/* send a text msg */
int send_message(char const *name, url_string_t const *url)
{
nua_handle_t *op;
sip_to_t *to;
op = su_zalloc(cli->cli_home, (sizeof (nua_handle_t *)));
if (op==NULL)
{ printf("can not create operation context information\n");
return 0;
}
/*Destination address */
to = sip_to_create(NULL,url);
if (!to) return 0;
to->a_display=name;
op = nua_handle(cli->cli_nua, NULL, SIPTAG_TO(to), TAG_END());
printf (" create operation handle: OK\n");
if (op==NULL)
{ printf ("can not access operation handle\n");
return 0;
}
nua_message(op, SIPTAG_CONTENT_TYPE_STR("text/plain"),
SIPTAG_PAYLOAD_STR("hello world"),TAG_END());
printf (" send msg: OK\n");
return (int) op;
}
int runsipmainloop(void)
{
if (cli->cli_nua !=NULL)
{
printf("entering main loop for processing of messages\n");
su_root_run(cli->cli_root);
printf ("entered main loop");
}
return 0;
}
int sipcleanup(void)
{
nua_destroy(cli->cli_nua);
su_root_destroy(cli->cli_root);
cli->cli_root=NULL;
su_home_deinit(cli->cli_home);
su_deinit();
return 0;
}
/* This callback will be called by SIP stack to
* process incoming events
*/
void event_callback(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[])
{ switch (event){
case nua_i_invite:
printf("invitation has been sent");
break;
case nua_i_active:
printf("receive invitation");
break;
case nua_r_invite:
printf("responseinvitation");
break;
defult:
printf("unkown event");
}
}
/********************************************************************************/
_________________________________________________________________
Making the world a better place one message at a time.
http://www.imtalkathon.com/?source=EML_WLH_Talkathon_BetterPlace
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel