Search in sources :

Example 26 with DiameterMessage

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;
}
Also used : AccountingAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.base.events.SessionTerminationAnswerImpl) CapabilitiesExchangeAnswerImpl(org.mobicents.slee.resource.diameter.base.events.CapabilitiesExchangeAnswerImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ReAuthAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ReAuthAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) DisconnectPeerAnswerImpl(org.mobicents.slee.resource.diameter.base.events.DisconnectPeerAnswerImpl) DeviceWatchdogAnswerImpl(org.mobicents.slee.resource.diameter.base.events.DeviceWatchdogAnswerImpl)

Example 27 with DiameterMessage

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;
}
Also used : DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterActivity(net.java.slee.resource.diameter.base.DiameterActivity) AvpDataException(org.jdiameter.api.AvpDataException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) OperationNotSupportedException(javax.naming.OperationNotSupportedException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException)

Example 28 with DiameterMessage

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());
}
Also used : DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) FireableEventType(javax.slee.resource.FireableEventType)

Example 29 with DiameterMessage

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);
}
Also used : ShServerSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerSubscriptionActivityImpl) UserDataRequest(net.java.slee.resource.diameter.sh.events.UserDataRequest) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) ShServerSessionImpl(org.jdiameter.server.impl.app.sh.ShServerSessionImpl) DiameterMessageFactoryImpl(org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl) ShServerMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.server.ShServerMessageFactoryImpl) ServerShSession(org.jdiameter.api.sh.ServerShSession) ShServerSessionDataLocalImpl(org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl) Test(org.junit.Test) ShClientActivityAnswerCreationTest(org.mobicents.slee.resource.diameter.sh.client.tests.activities.ShClientActivityAnswerCreationTest)

Example 30 with DiameterMessage

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);
}
Also used : PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) ClientShSession(org.jdiameter.api.sh.ClientShSession) ArrayList(java.util.ArrayList) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ShClientSessionImpl(org.jdiameter.client.impl.app.sh.ShClientSessionImpl) ShClientSessionDataLocalImpl(org.jdiameter.client.impl.app.sh.ShClientSessionDataLocalImpl) ShClientMessageFactoryImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientMessageFactoryImpl) PushNotificationRequest(net.java.slee.resource.diameter.sh.events.PushNotificationRequest) ShClientSubscriptionActivityImpl(org.mobicents.slee.resource.diameter.sh.client.ShClientSubscriptionActivityImpl) DiameterShAvpFactoryImpl(org.mobicents.slee.resource.diameter.sh.DiameterShAvpFactoryImpl) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)34 Message (org.jdiameter.api.Message)14 FireableEventType (javax.slee.resource.FireableEventType)12 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)4 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)4 OperationNotSupportedException (javax.naming.OperationNotSupportedException)3 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)3 IOException (java.io.IOException)2 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)2 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)2 UserDataRequest (net.java.slee.resource.diameter.sh.events.UserDataRequest)2 ServerShSession (org.jdiameter.api.sh.ServerShSession)2 ShServerSessionDataLocalImpl (org.jdiameter.server.impl.app.sh.ShServerSessionDataLocalImpl)2 ShServerSessionImpl (org.jdiameter.server.impl.app.sh.ShServerSessionImpl)2 DiameterMessageFactoryImpl (org.mobicents.slee.resource.diameter.base.DiameterMessageFactoryImpl)2 AbortSessionAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AbortSessionAnswerImpl)2 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)2 CapabilitiesExchangeAnswerImpl (org.mobicents.slee.resource.diameter.base.events.CapabilitiesExchangeAnswerImpl)2