Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Isolating the session plugin - dialplan issues.
Author Message
troelsmunch
Brekeke Member


Joined: 31 Jan 2007
Posts: 18

PostPosted: Thu Apr 10, 2008 2:01 am    Post subject: Isolating the session plugin - dialplan issues. Reply with quote

1. Brekeke Product Name and version: 2.0.7.2

2. Java version:Latest

3. OS type and the version: Win2k3 Server

4. Your problem:

I have the following dialplan (in this specific order):

Matching:
$request=^INVITE

Deploy:
To=(.+)
$session=com.test.dialplan.plugin.adpfordialplan
$continue=true


Matching:
$request=^INVITE
$dialplan.findtonumber( To )=(.+)

Deploy:
$target="someIP":5060
To=sip:%1@"someIP"

Both the session and the dialplan plugin works very good.

A little brief information is needed to understand my problem:
The session plugin is primarily for accounting. It checks the callers current balance within our system and sets a scheduled timeout for the call according to the user's balance and the dialed destination. I the session plugin I look up the corresponding CallPatern (Destination) and price based on the dialed number - if the session plugin can not determine the destination of the call, hence can not decide how to charge the call, the call is ended.

The dialplan plugin will in some cases change the To field. In some cases the plugin adds some digits in the beginning of the dialed number, because it is need by our service provider.

Now, the problem is when the To field is changed by the dialplan plugin then the session plugin can not look up the number, because the number does not match any of my callpaterns due to the changed to field.

I would like to be able to isolate the the first dialplan rule (session plugin) so that whatever is done later in the dialplan would not affect the session plugin.

I very open to other solutions as well, as long as it is done within the dialplan.

Thanks!
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Thu Apr 10, 2008 10:24 am    Post subject: Reply with quote

Hi troelsmunch,

How about this idea??

Matching:
$request = ^INVITE
To = (.+)

Deploy:
X-Original-To = %1
$session = com.test.dialplan.plugin.adpfordialplan
$continue = true


By the above new your first DialPlan rule, the original To header is stored in "X-Original-To" header.

So you can obtain original To's information by "X-Original-To" in the session plugin even if the DialPlan plugin changes To header.
Back to top
View user's profile
troelsmunch
Brekeke Member


Joined: 31 Jan 2007
Posts: 18

PostPosted: Thu Apr 10, 2008 11:07 am    Post subject: Reply with quote

lakeview wrote:

So you can obtain original To's information by "X-Original-To" in the session plugin even if the DialPlan plugin changes To header.


Hi Lakeview,

That sure look interesting.
One question... how do I obtain the "X-Original-To" in my session plugin?

Thanks a lot!
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Thu Apr 10, 2008 12:39 pm    Post subject: Reply with quote

Hi

Try the following in your session plugin.

Code:
String  originalTo = sippacket.getValue( "X-Original-To" ) ;
Back to top
View user's profile
troelsmunch
Brekeke Member


Joined: 31 Jan 2007
Posts: 18

PostPosted: Thu Apr 10, 2008 1:09 pm    Post subject: Reply with quote

lakeview wrote:

Code:
String  originalTo = sippacket.getValue( "X-Original-To" ) ;


But is the sippacket object passed on to the session plugin?

My session plugin looks like this:

Code:
public class adpfordialplan extends AccountingBase
{
    String connectionUrl = "myConnectionURL";
    String jdbcPath = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    int mIntTalkTimeout;
   
    public adpfordialplan()
    {
        mIntTalkTimeout = 0;   
    }

    public int eventSessionStart(EventStat evstat, String[] argprm)
    {
        logic objLogic = new logic();
       
        beginSession objBeginSession = objLogic.sessionStart (evstat);

        if (objBeginSession.getMIntMaxTalktime () > 0)
            mIntTalkTimeout = objBeginSession.getMIntMaxTalktime();
   else if (objBeginSession.getMIntSIPreturnValue() == 0)
   {
       java.util.Date dateToday = new java.util.Date();
       return 402;
   }
   return objBeginSession.getMIntSIPreturnValue ();
    }
   
    public void eventTalkStart(EventStat evstat)
    {
   setScheduleTerminate(mIntTalkTimeout);
    }

    public void eventTalkEnd(EventStat evstat)
    {
        //Nothing here
    }
   
    public void eventSessionEnd(EventStat evstat)
    {
        logic objLogic = new logic();
        objLogic.sessionEnd (evstat, getTalkLength ());
    }

    public void eventTimerup(EventStat evstat, long id)
    {
       
    }
}


A lot code is the my "logic" object, but as you can see, I do not have the sippacket object here - if you know a way to get it I would greatly appreciate it.

Thanks
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Thu Apr 10, 2008 7:21 pm    Post subject: Reply with quote

Hi,

Please modify your eventSessionStart as the following...

Code:
public int eventSessionStart( EventStat evstat, String[] argprm )
{
  String  originalTo = null ;
  if ( ( argprm != null ) && ( argprm.length >= 2 ) && ( argprm[1] != null ) ) {
    // get the original To header
    originalTo = argprm[1] ;
  }

    //
    // Your current code here.
    //
}


And use the DialPlan rule below.

Quote:
Matching:
$request = ^INVITE
To = (.+)

Deploy:
$session = com.test.dialplan.plugin.adpfordialplan %1
$continue = true


I tried the above and it worked.
Back to top
View user's profile
troelsmunch
Brekeke Member


Joined: 31 Jan 2007
Posts: 18

PostPosted: Fri Apr 11, 2008 12:31 am    Post subject: Reply with quote

Thank you so very much. I've not tried it yet, but I will a bit later today. I really appreciate you taking the time to help out!

Thanks!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1