use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class DiameterActivityImpl method sendSyncMessage.
public DiameterMessage sendSyncMessage(DiameterMessage message) {
DiameterMessage answer = null;
Message receivedMessage = doSendMessage(message);
if (receivedMessage != null) {
if (!receivedMessage.isRequest()) {
if (receivedMessage.isError()) {
answer = new ErrorAnswerImpl(receivedMessage);
} else {
switch(receivedMessage.getCommandCode()) {
case AbortSessionAnswer.commandCode:
answer = new AbortSessionAnswerImpl(receivedMessage);
break;
case AccountingAnswer.commandCode:
answer = new AccountingAnswerImpl(receivedMessage);
break;
case CapabilitiesExchangeAnswer.commandCode:
answer = new CapabilitiesExchangeAnswerImpl(receivedMessage);
break;
case DeviceWatchdogAnswer.commandCode:
answer = new DeviceWatchdogAnswerImpl(receivedMessage);
break;
case DisconnectPeerAnswer.commandCode:
answer = new DisconnectPeerAnswerImpl(receivedMessage);
break;
case ReAuthAnswer.commandCode:
answer = new ReAuthAnswerImpl(receivedMessage);
break;
case SessionTerminationAnswer.commandCode:
answer = new SessionTerminationAnswerImpl(receivedMessage);
break;
default:
logger.error("Received an unknown type of Message for Base Activity: " + receivedMessage);
break;
}
}
} else {
logger.error("Received a REQUEST message when expecting an ANSWER.");
}
} else {
logger.debug("No answer received. Returning null.");
}
return answer;
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class DiameterShServerResourceAdaptor method fireEvent.
// Event and Activities management -------------------------------------
public boolean fireEvent(Object event, ActivityHandle handle, FireableEventType eventID, Address address, boolean useFiltering, boolean transacted) {
if (useFiltering && eventIDFilter.filterEvent(eventID)) {
if (tracer.isFineEnabled()) {
tracer.fine("Event " + eventID + " filtered");
}
} else if (eventID == null) {
tracer.severe("Event ID for " + eventID + " is unknown, unable to fire.");
} else {
if (tracer.isFineEnabled()) {
tracer.fine("Firing event " + event + " on handle " + handle);
}
try {
/* TODO: Support transacted fire of events when in cluster
if (transacted){
this.raContext.getSleeEndpoint().fireEventTransacted(handle, eventID, event, address, null, EVENT_FLAGS);
}
else */
{
DiameterActivity activity = (DiameterActivity) getActivity(handle);
if (activity instanceof ShServerActivityImpl) {
((ShServerActivityImpl) activity).fetchSessionData((DiameterMessage) event, true);
} else if (activity instanceof ShServerSubscriptionActivityImpl) {
((ShServerSubscriptionActivityImpl) activity).fetchSessionData((DiameterMessage) event, true);
}
this.raContext.getSleeEndpoint().fireEvent(handle, eventID, event, address, null, EVENT_FLAGS);
}
return true;
} catch (Exception e) {
tracer.severe("Error firing event.", e);
}
}
return false;
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class DiameterShServerResourceAdaptor method fireEvent.
/*
* (non-Javadoc)
* @see org.mobicents.slee.resource.diameter.base.handlers.BaseSessionCreationListener#fireEvent(java.lang.String, org.jdiameter.api.Request, org.jdiameter.api.Answer)
*/
public void fireEvent(String sessionId, Message message) {
DiameterMessage event = (DiameterMessage) createEvent(message);
FireableEventType eventId = eventIdCache.getEventId(eventLookup, message);
this.fireEvent(event, getActivityHandle(sessionId), eventId, null, true, message.isRequest());
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class ShServerActivityAnswerCreationTest method testShServerSubscriptionActivityAnswerCreation.
@Test
public void testShServerSubscriptionActivityAnswerCreation() throws Exception {
ServerShSession session = new ShServerSessionImpl(new ShServerSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ServerShSessionListenerImpl());
DiameterMessageFactoryImpl msgFactory = new DiameterMessageFactoryImpl(session.getSessions().get(0), stack, null, null);
ShClientMessageFactoryImpl factory = new ShClientMessageFactoryImpl(session.getSessions().get(0), stack);
UserDataRequest udr = factory.createUserDataRequest();
net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest pur = factory.createProfileUpdateRequest();
net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest snr = factory.createSubscribeNotificationsRequest();
ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
list.add(udr);
list.add(pur);
list.add(snr);
ShServerSubscriptionActivityImpl activity = new ShServerSubscriptionActivityImpl(new ShServerMessageFactoryImpl(msgFactory, session.getSessions().get(0), stack, diameterShAvpFactory), diameterShAvpFactory, session, null, null);
DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class ShClientActivityAnswerCreationTest method testShClientActivityAnswerCreation.
@Test
public void testShClientActivityAnswerCreation() throws Exception {
ClientShSession session = new ShClientSessionImpl(new ShClientSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ClientShSessionListenerImpl());
PushNotificationRequest pnr = new PushNotificationRequestImpl(stack.getSessionFactory().getNewSession().createRequest(PushNotificationRequest.commandCode, SH_APP_ID, "mobicents.org", "hss.mobicents"));
ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
list.add(pnr);
ShClientSubscriptionActivityImpl activity = new ShClientSubscriptionActivityImpl(new ShClientMessageFactoryImpl(session.getSessions().get(0), stack), new DiameterShAvpFactoryImpl(diameterAvpFactory), session, null, null);
DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
Aggregations