...
Code Block |
---|
java -jar start.jar --ini=start-cipango.ini etc/diameter.xml |
Logging
Diameter messages are logged in the file ${jetty.home}/logs/yyyy_mm_dd.diameter.log
(replace yyyy_mm_dd by the current date).
API
Javadoc
Javadoc is available at http://www.cipango.org/javadoc/diameter-2.0/.
...
Cipango makes an instance of org.cipango.diameter.api.DiameterFactory
available to servlets via the servlet context attribute of the same name, org.cipango.diameter.api.DiameterFactory
.
Usage
Send request
The following code sample illustrates how to create an UDR
request:
Code Block | ||||
---|---|---|---|---|
| ||||
protected void doRequest(SipServletRequest sipRequest) throws ServletException, IOException { DiameterFactory factory = (DiameterFactory) getServletContext().getAttribute(DiameterFactory.class.getName()); DiameterRequest DiameterServletRequest request = factory.createRequest(sipRequest.getApplicationSession(),Sh.SH_APPLICATION_ID, Sh.UDR,"home1.net","hss1.home1.net"); AVP<AVPList> AVPList userIdentity = new factory.createAVPList(Sh.USER_IDENTITYAVPList(); userIdentity.addValueadd(Cx.PUBLIC_IDENTITY, "sip:alice@atlanta.com"); request.addAVP(add(Sh.USER_IDENTITY, userIdentity); request.add(Sh.DATA_REFERENCE, Sh.DataReference.IMSUserState); request.setAttribute("request", sipRequest); request.send(); } |
Logging
...
Handling answer
When the UDA answer
is received, the handle
method of the DiameterListener
interface is invoked and the requested data could be retrieved as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
public void handle(DiameterServletMessage message) throws IOException
{
try
{
if (!message.isRequest())
{
DiameterServletAnswer answer = (DiameterServletAnswer) message;
byte[] data = answer.get(Sh.USER_DATA);
// process sh data
SipServletRequest request = (SipServletRequest) answer.getRequest().getAttribute("request");
SipServletResponse response = request.createResponse(200);
response.send();
response.getApplicationSession().invalidate();
}
else
// Error processing
}
catch (Throwable e)
{
// Error processing
}
}
|