use of net.java.client.slee.resource.http.HttpClientActivity in project charging-server by RestComm.
the class HTTPClientSbb method onResponseEvent.
// Event handler methods
public void onResponseEvent(ResponseEvent event, ActivityContextInterface aci) {
HttpResponse response = event.getHttpResponse();
if (tracer.isInfoEnabled()) {
tracer.info("[<<] Received HTTP Response. Status Code = " + response.getStatusLine().getStatusCode());
if (tracer.isFineEnabled()) {
try {
tracer.fine("[<<] Received HTTP Response. Response Body = [" + EntityUtils.toString(response.getEntity()) + "]");
} catch (Exception e) {
tracer.severe("[xx] Failed reading response body", e);
}
}
}
// end http activity
((HttpClientActivity) aci.getActivity()).endActivity();
// call back parent
HashMap params = (HashMap) event.getRequestApplicationData();
RatingInfo ratInfo = buildRatingInfo(response, params);
final DiameterChargingServer parent = (DiameterChargingServer) sbbContext.getSbbLocalObject().getParent();
parent.getRateForServiceResult(ratInfo);
}
use of net.java.client.slee.resource.http.HttpClientActivity in project charging-server by RestComm.
the class HTTPClientSbb method getRateForServiceAsync.
public RatingInfo getRateForServiceAsync(HashMap params) {
String sessionIdFromRequest = params.get("SessionId").toString();
HttpClientActivity clientActivity = null;
try {
clientActivity = raSbbInterface.createHttpClientActivity(true, null);
} catch (StartActivityException e) {
tracer.severe("[xx] Failed creating HTTP Client Activity to send HTTP Request to Rating Engine.");
return new RatingInfo(-1, sessionIdFromRequest);
}
ActivityContextInterface clientAci = httpClientAci.getActivityContextInterface(clientActivity);
clientAci.attach(sbbContext.getSbbLocalObject());
params.put("startTime", System.currentTimeMillis());
HttpPost httpPost = buildHTTPRequest(params);
// Asynchronous call
clientActivity.execute(httpPost, params);
tracer.info("[>>] Sent HTTP Request to Rating Client in asynchronous mode.");
return null;
}
Aggregations