Пример #1
0
PDU SmppClient::sendCommand(PDU &pdu)
{
	sendPdu(pdu);

	PDU resp = readPduResponse(pdu.getSequenceNo(), pdu.getCommandId());

	switch (resp.getCommandStatus()) {
		case smpp::ESME_RINVPASWD:
			throw smpp::InvalidPasswordException(smpp::getEsmeStatus(resp.getCommandStatus()));
			break;
		case smpp::ESME_RINVSYSID:
			throw smpp::InvalidSystemIdException(smpp::getEsmeStatus(resp.getCommandStatus()));
			break;
		case smpp::ESME_RINVSRCADR:
			throw smpp::InvalidSourceAddressException(smpp::getEsmeStatus(resp.getCommandStatus()));
			break;
		case smpp::ESME_RINVDSTADR:
			throw smpp::InvalidDestinationAddressException(smpp::getEsmeStatus(resp.getCommandStatus()));
			break;
	}

	if (resp.getCommandStatus() != smpp::ESME_ROK) throw smpp::SmppException(
			smpp::getEsmeStatus(resp.getCommandStatus()));

	return resp;
}
Пример #2
0
void SmppClient::unbind()
{
	checkConnection();
	PDU pdu(smpp::UNBIND, 0, nextSequenceNumber());
	PDU resp = sendCommand(pdu);

	uint32_t pduStatus = resp.getCommandStatus();

	if (pduStatus != smpp::ESME_ROK) throw smpp::SmppException(smpp::getEsmeStatus(pduStatus));

	state = OPEN;
}