Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
doTerminate()
Author Message
ehality
Brekeke Junior Member


Joined: 06 Feb 2008
Posts: 6

PostPosted: Sun Oct 21, 2012 12:33 pm    Post subject: doTerminate() Reply with quote

1. Brekeke Product Name and version:Brekeke SIP Server for Brekeke PBX, Version 3.0.7.0

2. Java version:7

3. OS type and the version:

4. UA (phone), gateway or other hardware/software involved:

5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/networkpatterns.html :

6. Your problem:

Using doTerminate() in a prepaid accounting plugin, I can retrieve the session Id (sid), caller and callee with no issues.

sometimes I would like to terminate the session, is there anyway to combine the sid with the doTerminate so I can terminate the specific session not anything else??
( it is not reflected any place in your developers guide, just a shy brief description for the doTerminate function)

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


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Mon Oct 22, 2012 10:26 am    Post subject: Reply with quote

You can call doTerminate() from any event method in the plugin.
You don't have to care about the sid.

Why do you need to combine the sid?
Back to top
View user's profile
ehality
Brekeke Junior Member


Joined: 06 Feb 2008
Posts: 6

PostPosted: Mon Oct 22, 2012 11:18 am    Post subject: Reply with quote

Thanks Lakeview
Quote:
You don't have to care about the sid.


I am Implementing a prepaid with different rates Grey Line, Standard and premium

So if a premium caller invite is received and I have no more unused ITSP extensions I have to disconnect one of the grey line current callers and get the premium to take over "I know it sounds a little bit mean but this is my assignment Smile )

So, upon invite my plugin needs to log each sid, identify caller grey, standard or premium, start authentication authorize the call and give priority to the Premium user among the others and some times I need to disconnect an active session with doTerminate() to take over this ITSP out line and get the premium user call connected

there should be some way to do that ?
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Mon Oct 22, 2012 6:28 pm    Post subject: Reply with quote

How do you recognize such a user level?


The following DialPlan rule can disconnect a session automatically after 60000ms (=1sec) if a caller is "grey_line_user".

Matching Patterns
$request = ^INVITE
From = sip:grey_line_user@
Deploy Patterns
&net.sip.timeout.talking = 60000
&net.sip.timeout.expand.talking = false
$continue = true
Back to top
View user's profile
ehality
Brekeke Junior Member


Joined: 06 Feb 2008
Posts: 6

PostPosted: Tue Oct 23, 2012 2:39 am    Post subject: Reply with quote

The user type is something we implemented that has nothing to do with brekeke it depends on the agreement between us and our clients, we offer 3 diffrent rates for the same called destinations, the only diffrent is that the premium package which is the the highest rate per minute insures the most reliability, while the grey package which is the cheapest one insures a much lower realiability and the standard is something in between

I can't control such scenario from a dial plan as the user account type logged on a separate database so I have to retrive it and handle the call initiation based on the package data, rate per minute and balance left on the account from a java plugin, I am successful in everything so far except the doTerminate(sid) that I was hoping to do?

Any suggestions?
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Tue Oct 23, 2012 10:13 am    Post subject: Reply with quote

Who calls doTerminate ? Is it the plugin self?
If the plugin calls doTerminate, you don't need to specify the SID.

How do you associate the SID and the user type?
The SID is a unique number not Caller-ID.
Back to top
View user's profile
ehality
Brekeke Junior Member


Joined: 06 Feb 2008
Posts: 6

PostPosted: Tue Oct 23, 2012 1:07 pm    Post subject: Reply with quote

-Inivite is detected
-Plugin started
-Plugin collects Caller, callee and sid using eventstat
-plugin connects to external database to check caller available balance
-plugin check the callee number against rates table
-plugin checks the logging table to count how many ITSP lines are in use say 5 of 5 lines are currently in use say the 5th is a grey package subscriber
-Doing some Math to calculate set the setscheduleTerminate(seconds)
log the sid in the logging table and set an active call flag

if a new user just dialing in and he bought the premium package so he has priority over any other lower package that so I need to disconnect the 5th caller by polling his sid from the logging database and get the premium caller to takeover the line

The Plugin calls the doTerminate
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Tue Oct 23, 2012 1:21 pm    Post subject: Reply with quote

Try this code.

Code:

com.brekeke.net.sip.sv.SessionStat  sessionstat = null;
sessionstat = (com.brekeke.net.sip.sv.SessionStat)(listener.getSession( SID ) ) ;
if ( sessionstat != null ) {
   sessionstat.ssplg.doTerminate() ;
}
Back to top
View user's profile
ehality
Brekeke Junior Member


Joined: 06 Feb 2008
Posts: 6

PostPosted: Tue Oct 23, 2012 1:38 pm    Post subject: Reply with quote

Thanks for your help, I will try it and give you a feedback
a quick question
is there any guide for such script
com.brekeke.net.sip.sv.SessionStat
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Tue Oct 23, 2012 1:58 pm    Post subject: Reply with quote

If you are Brekeke's Technology Partner or DEV-TSC member, you can ask them to provide API information.
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