Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

I wrote a sip Servlet. I need to watch call count continuously  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I wrote a Sip Servlet . Sip Clients talks over me. This is OK.
Now i need to calculate call counts between them. May be this is simple but i need much more than this.
For example REMANING_CALL_DURATION between 2 clients is 1 hour or 28 minutes,etc.
My Application have to warn them in their last 1 minute.

To be clear i will tell in the code sample.

XxxSipServlet extends SipServlet implements Servlet {
..
..
public void doAckReceived(SipServletRequest request) {
...
..
//Here in this method i understand the call is established
between two clients.
...
}


public void byeReceived(SipServletRequest request) {
..
..
//Here in this method i understand the call is ended.
..
}
..
}

What can i do ? Any Suggestions or code examples will be appreciated.

Thanks a lot. :roll:

[ November 15, 2008: Message edited by: Bear Bibeault ]
[ November 15, 2008: Message edited by: alp carsikarsi ]
 
Author and ninkuma
Marshal
Posts: 66799
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"a oz", please check your private messages for an important administrative matter.
 
alp carsikarsi
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a solution but i need help ... Please somebody help me ?
In AlpTimerTask's run method servlet.activeSipCallSessions is null.
But actually activeSipCallSessions can't be null.
Why i see it null in my TimerTask's run method ?
What will i do ?

Here is some part of my code :

AlpSipServlet

public class AlpSipServlet extends SipServlet implements Servlet {
..
public static HashMap activeSipCallSessions = new HashMap();
..
public void init(ServletConfig sc) throws ServletException {
..
timer = new Timer();
timer.schedule(new AlpTimerTask("Listen Remaning Call Count",this), 10000, 50000);
..
}

public void doAckReceived(SipServletRequest request)
{
..
AlpSipServlet.activeSipCallSessions.put(sipAppSession.getId(), sipAppSession);
..
}

public void byeReceived(SipServletRequest request)
{
..
AlpSipServlet.activeSipCallSessions.remove(sipAppSession.getId());
..
}

In my AlpTimerTask.java :

public class AlpTimerTask extends TimerTask {
..
private AlpSipServlet servlet = null;
..
public AlpTimerTask(String name,AlpSipServlet servlet) {
this.name = name;
this.servlet =servlet;
}

public void run() {
logger.debug("<AlpTimerTask.run>Do something!!!");
Collection activeCalls = null;
if (servlet.activeSipCallSessions != null)
activeCalls = servlet.activeSipCallSessions.values();

if (activeCalls != null)
for (Iterator iterator = activeCalls.iterator(); iterator.hasNext() {
SipApplicationSession sipAppSession = (SipApplicationSession) iterator.next();
logger.debug(" Active call session id : " + sipAppSession.getId());
}
if (activeCalls == null || activeCalls.size() == 0)
logger.debug("No active calls.");

}

}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!