File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes I wrote a sip Servlet. I need to watch call count  continuously Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "I wrote a sip Servlet. I need to watch call count  continuously" Watch "I wrote a sip Servlet. I need to watch call count  continuously" New topic
Author

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

alp carsikarsi
Ranch Hand

Joined: Dec 27, 2005
Posts: 40
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 ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

"a oz", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
alp carsikarsi
Ranch Hand

Joined: Dec 27, 2005
Posts: 40
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.");

}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I wrote a sip Servlet. I need to watch call count continuously