use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl 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 org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.
the class DiameterShServerResourceAdaptor method createEvent.
/**
* Create Event object from a JDiameter message (request or answer)
*
* @return a DiameterMessage object wrapping the request/answer
* @throws OperationNotSupportedException
*/
private DiameterMessage createEvent(Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
boolean isRequest = message.isRequest();
switch(commandCode) {
case // PNR/PNA
PushNotificationRequest.commandCode:
return isRequest ? new PushNotificationRequestImpl(message) : new PushNotificationAnswerImpl(message);
case // PUR/PUA
ProfileUpdateRequest.commandCode:
return isRequest ? new ProfileUpdateRequestImpl(message) : new ProfileUpdateAnswerImpl(message);
case // SNR/SNA
SubscribeNotificationsRequest.commandCode:
return isRequest ? new SubscribeNotificationsRequestImpl(message) : new SubscribeNotificationsAnswerImpl(message);
case // UDR/UDA
UserDataRequest.commandCode:
return isRequest ? new UserDataRequestImpl(message) : new UserDataAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.
the class DiameterShClientResourceAdaptor method createEvent.
/**
* Create Event object from a JDiameter message (request or answer)
*
* @return a DiameterMessage object wrapping the request/answer
* @throws OperationNotSupportedException
*/
private DiameterMessage createEvent(Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
boolean isRequest = message.isRequest();
switch(commandCode) {
case // PNR/PNA
PushNotificationRequestImpl.commandCode:
return isRequest ? new PushNotificationRequestImpl(message) : new PushNotificationAnswerImpl(message);
case // PUR/PUA
ProfileUpdateRequestImpl.commandCode:
return isRequest ? new ProfileUpdateRequestImpl(message) : new ProfileUpdateAnswerImpl(message);
case // SNR/SNA
SubscribeNotificationsRequestImpl.commandCode:
return isRequest ? new SubscribeNotificationsRequestImpl(message) : new SubscribeNotificationsAnswerImpl(message);
case // UDR/UDA
net.java.slee.resource.diameter.sh.events.UserDataRequest.commandCode:
return isRequest ? new UserDataRequestImpl(message) : new UserDataAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.
the class DiameterGxResourceAdaptor method createEvent.
/**
* Create Event object from a JDiameter message (request or answer).
*
* @return a DiameterMessage object wrapping the request/answer
* @throws OperationNotSupportedException
*/
private DiameterMessage createEvent(final Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
final int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
final boolean isRequest = message.isRequest();
switch(commandCode) {
case // CCR/CCA
GxCreditControlRequest.commandCode:
return isRequest ? new GxCreditControlRequestImpl(message) : new GxCreditControlAnswerImpl(message);
case // ASR/ASA
AbortSessionAnswer.commandCode:
return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message);
case // STR/STA
SessionTerminationAnswer.commandCode:
return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message);
case // RAR/RAA
GxReAuthAnswer.commandCode:
return isRequest ? new GxReAuthRequestImpl(message) : new GxReAuthAnswerImpl(message);
case // ACR/ACA
AccountingAnswer.commandCode:
return isRequest ? new AccountingRequestImpl(message) : new AccountingAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
use of org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl in project jain-slee.diameter by RestComm.
the class GqSessionActivityImpl method sendSyncMessage.
@Override
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 GqAARequest.COMMAND_CODE:
answer = new GqAARequestImpl(receivedMessage);
break;
case GqAbortSessionRequest.COMMAND_CODE:
answer = new GqAbortSessionRequestImpl(receivedMessage);
break;
case GqReAuthRequest.COMMAND_CODE:
answer = new GqReAuthRequestImpl(receivedMessage);
break;
case GqSessionTerminationRequest.COMMAND_CODE:
answer = new GqSessionTerminationRequestImpl(receivedMessage);
break;
default:
logger.error("Received an unknown type of Message for Gq' Activity: " + receivedMessage);
break;
}
}
} else {
logger.error("Received a REQUEST message when expecting an ANSWER.");
}
} else {
logger.debug("No answer received. Returning null.");
}
return answer;
}
Aggregations