Skip to content

Commit

Permalink
Fixed Client and Server SLgSessionListeners to suit their roles for L…
Browse files Browse the repository at this point in the history
…RA and LRA methods and derived changes. Issues #37 and #38, PR #111
  • Loading branch information
Fernando Mendioroz committed Aug 1, 2017
1 parent 5b74804 commit a8e37a3
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent an
void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocationRequest request, ProvideLocationAnswer answer)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;

void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request)
void doLocationReportRequestEvent(ClientSLgSession session, LocationReportRequest request)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void doOtherEvent(AppSession session, AppRequestEvent request, AppAnswerEvent an
void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocationRequest request)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;

void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer)
void doLocationReportAnswerEvent(ServerSLgSession session, LocationReportRequest request, LocationReportAnswer answer)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ public void sendLocationReportAnswer(LocationReportAnswer answer)
send(Event.Type.SEND_MESSAGE, null, answer);
}

/*public void sendLocationReportRequest(LocationReportRequest request)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
send(Event.Type.SEND_MESSAGE, request, null);
}*/

public void receivedSuccessMessage(Request request, Answer answer) {
AnswerDelivery rd = new AnswerDelivery();
rd.session = this;
Expand Down Expand Up @@ -187,17 +182,12 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE
break;

case RECEIVE_LRR:
/*newState = SLgSessionState.TERMINATED;
setState(newState);
listener.doLocationReportAnswerEvent(this, (LocationReportRequest) localEvent.getRequest(),
(LocationReportAnswer) localEvent.getAnswer());
break;*/
this.sessionData.setBuffer((Request) ((AppEvent) event.getData()).getMessage());
super.cancelMsgTimer();
super.startMsgTimer();
newState = SLgSessionState.MESSAGE_SENT_RECEIVED;
setState(newState);
listener.doLocationReportRequestEvent((ServerSLgSession) this, (LocationReportRequest) event.getData());
listener.doLocationReportRequestEvent(this, (LocationReportRequest) event.getData());
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ClientSLgSessionListener getClientSessionListener() {
}

/**
* @param clientSessionListener theclientSessionListener to set
* @param clientSessionListener the clientSessionListener to set
*/
public void setClientSessionListener(ClientSLgSessionListener clientSessionListener) {
this.clientSessionListener = clientSessionListener;
Expand Down Expand Up @@ -270,13 +270,13 @@ public LocationReportAnswer createLocationReportAnswer(Answer answer) {
return new LocationReportAnswerImpl(answer);
}

public void doLocationReportRequestEvent(ServerSLgSession appSession, LocationReportRequest request)
public void doLocationReportRequestEvent(ClientSLgSession appSession, LocationReportRequest request)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
logger.info("Diameter SLg Session Factory :: doLocationReportRequestEvent :: appSession[{}], Request[{}]", appSession,
request);
}

public void doLocationReportAnswerEvent(ClientSLgSession appSession, LocationReportRequest request,
public void doLocationReportAnswerEvent(ServerSLgSession appSession, LocationReportRequest request,
LocationReportAnswer answer)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
logger.info("Diameter SLg Session Factory :: doLocationReportAnswerEvent :: appSession[{}], Request[{}], Answer[{}]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ public void sendLocationReportRequest(LocationReportRequest request)
send(Event.Type.SEND_MESSAGE, request, null);
}

/*public void sendLocationReportAnswer(LocationReportAnswer answer)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
send(Event.Type.SEND_MESSAGE, null, answer);
}*/

@SuppressWarnings("unchecked")
public <E> E getState(Class<E> stateType) {
return stateType == SLgSessionState.class ? (E) this.sessionData.getSLgSessionState() : null;
Expand Down Expand Up @@ -130,7 +125,7 @@ public boolean handleEvent(StateEvent event) throws InternalException, OverloadE
case RECEIVE_LRA:
newState = SLgSessionState.TERMINATED;
setState(newState);
listener.doLocationReportAnswerEvent((ClientSLgSession) this, (LocationReportRequest) localEvent.getRequest(),
listener.doLocationReportAnswerEvent(this, (LocationReportRequest) localEvent.getRequest(),
(LocationReportAnswer) localEvent.getAnswer());
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jdiameter.api.OverloadException;
import org.jdiameter.api.Request;
import org.jdiameter.api.RouteException;
import org.jdiameter.api.Session;
import org.jdiameter.api.app.AppAnswerEvent;
import org.jdiameter.api.app.AppRequestEvent;
import org.jdiameter.api.app.AppSession;
Expand Down Expand Up @@ -112,7 +113,7 @@ public void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocati
fail("Received \"PLA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null);
}

public void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request) throws InternalException, IllegalDiameterStateException,
public void doLocationReportRequestEvent(ClientSLgSession session, LocationReportRequest request) throws InternalException, IllegalDiameterStateException,
RouteException, OverloadException {
fail("Received \"LRR\" event, request[" + request + "], on session[" + session + "]", null);
}
Expand All @@ -131,10 +132,6 @@ public void fetchSession(String sessionId) throws InternalException {
this.serverSLgSession = stack.getSession(sessionId, ServerSLgSession.class);
}

/*public ServerSLgSession getServerSLgSession() {
return this.serverSLgSession;
}*/

// Attributes for Provide Location Request (PLR) and Location Report Answer
protected abstract int getSLgLocationType();
protected abstract String getUserName(); // IE: IMSI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jdiameter.api.OverloadException;
import org.jdiameter.api.Request;
import org.jdiameter.api.RouteException;
import org.jdiameter.api.Session;
import org.jdiameter.api.app.AppAnswerEvent;
import org.jdiameter.api.app.AppRequestEvent;
import org.jdiameter.api.app.AppSession;
Expand All @@ -40,6 +41,7 @@
import org.jdiameter.api.slg.events.LocationReportRequest;
import org.jdiameter.api.slg.events.ProvideLocationAnswer;
import org.jdiameter.api.slg.events.ProvideLocationRequest;
import org.jdiameter.client.impl.SessionImpl;
import org.jdiameter.common.impl.app.slg.LocationReportRequestImpl;
import org.jdiameter.common.impl.app.slg.ProvideLocationAnswerImpl;
import org.jdiameter.common.impl.app.slg.SLgSessionFactoryImpl;
Expand Down Expand Up @@ -106,7 +108,7 @@ public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocat
fail("Received \"PLR\" event, request[" + request + "], on session[" + session + "]", null);
}

public void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer) throws InternalException,
public void doLocationReportAnswerEvent(ServerSLgSession session, LocationReportRequest request, LocationReportAnswer answer) throws InternalException,
IllegalDiameterStateException, RouteException, OverloadException {
fail("Received \"LRA\" event, request[" + request + "], answer[" + answer + "], on session[" + session + "]", null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void doProvideLocationAnswerEvent(ClientSLgSession session, ProvideLocati
}

@Override
public void doLocationReportRequestEvent(ServerSLgSession session, LocationReportRequest request)
public void doLocationReportRequestEvent(ClientSLgSession session, LocationReportRequest request)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
if (this.receivedLRR) {
fail("Received LRR more than once", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void doProvideLocationRequestEvent(ServerSLgSession session, ProvideLocat
}

@Override
public void doLocationReportAnswerEvent(ClientSLgSession session, LocationReportRequest request, LocationReportAnswer answer)
public void doLocationReportAnswerEvent(ServerSLgSession session, LocationReportRequest request, LocationReportAnswer answer)
throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
Utils.printMessage(log, super.stack.getDictionary(), answer.getMessage(), false);

Expand Down

0 comments on commit a8e37a3

Please sign in to comment.