Failed to call user callback in SUBSCRIBE implemetation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Recently, I am implementing a SUBSCRIBE server to handing subscribe request with PJSIP, the program flow as following:

pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, &contact_uri, &dlg);

 /* Create server subscription and register user callback functions */
pjsip_evsub_create_uas(dlg, &evsub_user, rdata, 0, &sub);

/* Add content-type header */
pj_list_init(&hdr_list);

/* This function would send back 200 OK */
pjsip_evsub_accept(sub, rdata, st_code, &hdr_list);

the user call back of evsub_user as following:

static pjsip_evsub_user evsub_user =
{
  on_evsub_state,
  on_tsx_state,
  &on_rx_refresh,
  NULL,
  NULL,
  &on_server_timeout,
};

But  the callback on_rx_refresh and on_server_timeout are never called.

I dive into the source code of pjsip and found the code as following:

pjsip/src/pjsip-simple/evsub.c
/*
 * Transaction event processing by UAS, after subscription is accepted.
 */
static void on_tsx_state_uas( pjsip_evsub *sub, pjsip_transaction *tsx,
     pjsip_event *event)
{

    if (pjsip_method_cmp(&tsx->method, &sub->method) == 0 ||
pjsip_method_cmp(&tsx->method, &pjsip_subscribe_method) == 0) 
    {
        ... ... 
  
/* Only wants to handle the first event when the request is 
* received.
*/
if (tsx->state != PJSIP_TSX_STATE_TRYING)
   return;

        on_rx_refresh and on_server_timeout are called here.
       
     }

}


From the code above the call back it only be called when the transaction in PJSIP_TSX_STATE_TRYING state.
but the transaction would be switched into PJSIP_TSX_STATE_COMPLETE state, when I call  pjsip_evsub_accept(sub, rdata, st_code, &hdr_list); 


and from the PJSIP develop guide  http://www.pjsip.org/release/0.5.4/PJSIP-Dev-Guide.pdf (page 97)
on_evsub_state() would be called for state changed into ACCPETED when send out 200OK, but actually it is not called in my program.

I am not sure what I am missing.

Chenhui Xu
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux