How to get notification for every received SIP message?

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

 



Hi.

You can set-up a 'receive message sniffer' like this:


1.       Create a pjsip_module struct

pjsip_module CSoftphone::mod_app_message_sniffer =
{
    NULL, NULL,                             /* prev, next.        */
    { "mod-app-message-sniffer", 23 },    /* Name.          */
    -1,                                         /* Id             */
    PJSIP_MOD_PRIORITY_TSX_LAYER-1, /* Priority         */
    NULL,                     /* load()         */
    NULL,                     /* start()        */
    NULL,                     /* stop()         */
    NULL,                     /* unload()       */
    NULL,                 /* on_rx_request()    */
    &CSoftphone::ModAppMessageSnifferOnRxResponse,  /* on_rx_response() */
    &CSoftphone::ModAppMessageSnifferOnTxRequest,     /* on_tx_request()      */
    NULL,                     /* on_tx_response()     */
    NULL,                     /* on_tsx_state() */
};

2.  Register this module with the library:


    /* Initialize our module to sniff messages */
    pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), &mod_app_message_sniffer);


3.  Implement the static function to sniff the rx message:

pj_bool_t CSoftphone::mod_app_message_sniffer_on_rx_response(pjsip_rx_data *rdata)
{
    if (rdata->msg_info.msg->type == PJSIP_RESPONSE_MSG)
    {
      // bla bla this was a response message
    }

    return PJ_FALSE;
}

You'll note that in my module I created a sniffer for TX messages as well in a similar way.

Note also that you need to return PJ_FALSE in your handler if you are only sniffing the incoming (rx) messages and not actually handling them.

Regards.

Gary.


From: pjsip-bounces@xxxxxxxxxxxxxxx [mailto:pjsip-bounces at lists.pjsip.org] On Behalf Of Tom Merriewether
Sent: Wednesday, 27 June 2012 9:28 a.m.
To: pjsip list
Subject: Re: How to get notification for every received SIP message?

What I really want is any SIP message like NOTFY,INVITE,  etc.  and not just when an incoming call occurs.
On Mon, Jun 25, 2012 at 3:49 AM, Pawel Kuzak <pawel.kuzak at 1und1.de<mailto:pawel.kuzak at 1und1.de>> wrote:
Hi Thomas,

did you try the "on_incoming_call" callback from the pjsua_callbacks? Take a look here:
http://www.pjsip.org/pjsip/docs/html/structpjsua__callback.htm

Kind regards,
Paul

Am 22.06.2012 22:28, schrieb Tom Merriewether:

I am using the pjsua package and need to register to get a callback every time the stack receives an incoming message.
How do I do this?  I need to count the number and frequency of incoming messages when my iPhone app is in the background.
Any pointers on how to do this would be greatly appreciated.

TIA

--
Thomas Merriewether
Star2Star Communications


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

pjsip mailing list
pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org



--
Thomas Merriewether
Star2Star Communications



This e-mail contains IPFX information which may be privileged or confidential and is intended for use only by the individual(s) or entity named above. If you are not the intended recipient, note that disclosing, copying, distributing or using this information is prohibited. If you have received this e-mail in error, please advise immediately to the e-mail address above and permanently delete this message and any attachments. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. We monitor our e-mail system and may record your e-mails. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120626/4eb3cfd3/attachment.html>


[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