/** * If the PDU carries generic_nack despite of the class of the object.<br> * Under some wierd conditions there is need to "encapsulate" generic * negative acknowledge information into instance of class different * from <code>GenericNack</code> class. For example synchronous * call to the <code>Session</code>'s <code>submit</code> method * should return instance of <code>SubmitSMResp</code> class. * If the from some reason the SMSC returns generic_nack as a response * to the submit_sm, then the library must somehow overcome the type * checking for the return type and thus it creates instance of * <code>SubmitSMResp</code> but then it sets the command id * the id for generic_nack. * @return of the object carries generic_nack pdu rather than pdu * as could be indicated from the object's class * @see org.smpp.Session#checkResponse(PDU,Response) */ public boolean isGNack() { return getCommandId() == Data.GENERIC_NACK; }
public boolean equals(Object object) { if (object == null) { return false; } else { PDU pdu = (PDU) object; return pdu.getCommandId() == getCommandId(); } }
/** * Compares two PDU. Two PDUs are equal if their sequence number is equal * ( and now, if their command ids match as well). */ public boolean equals(Object object) { if ((object != null) && (object instanceof PDU)) { PDU pdu = (PDU) object; return (pdu.getSequenceNumber() == getSequenceNumber() && pdu.getCommandId() == getCommandId()); } else { return false; } }
pdu = (PDU)pduList.get(i); if (pdu != null) { if (pdu.getCommandId() == commandId) { try { newInstance = (PDU) (pdu.getClass().newInstance());
public String debugString() { String dbgs = "(pdu: "; dbgs += super.debugString(); dbgs += Integer.toString(getCommandLength()); dbgs += " "; dbgs += Integer.toHexString(getCommandId()); dbgs += " "; dbgs += Integer.toHexString(getCommandStatus()); dbgs += " "; if (sequenceNumberChanged) { dbgs += Integer.toString(getSequenceNumber()); } else { // it's likely that this will be the assigned seq number // (in simple cases :-) dbgs += "[" + (sequenceNumber + 1) + "]"; } dbgs += ") "; return dbgs; }
/** * Puts the <code>pdu</code> into the <code>pduQueue</code>. * * @param pdu the PDU to put into the queue * @see Queue */ private void enqueue(PDU pdu) { debug.write(DRXTX, "receiver enqueuing pdu."); synchronized (pduQueue) { pduQueue.enqueue(pdu); pduQueue.notifyAll(); } // HNK -- If you just received unbind_resp, don't block on // socket in TCPIPConnection.receive(), call stopProcessing() if (Data.UNBIND_RESP == pdu.getCommandId()) { stopProcessing(null); } }
/** * Checks if the session's state allows sending the PDU provided. * If not, then exception <code>WrongSessionStateException</code> is thrown. * For each state there is only a subset of PDUs which can be sent over the * session. For example, if the session is bound as a receiver, it cannot * submit messages, but it can send enquire link, generic nack etc. * This method checks the PDU type (command id) aganst matrix of allowed states. * The checking can be turned off, see * <a href="#disableStateChecking()">disableStateChecking</a>. * @param pdu the pdu which has to be checked if it's allowed in the current * state * @throws WrongSessionStateException if the session is not in the state * required * @see #checkState(int) * @see WrongSessionStateException */ public void checkState(PDU pdu) throws WrongSessionStateException { if (stateChecking) { Hashtable<Integer, Integer> pduMatrix = getStateMatrix(type); Integer commandIdInteger = new Integer(pdu.getCommandId()); Integer requestedStateInteger = pduMatrix == null ? null : pduMatrix.get(commandIdInteger); if (requestedStateInteger != null) { checkState(requestedStateInteger.intValue()); } else { if (disallowUnknownPDU) { throw new WrongSessionStateException(); } } } }
Response response = null; debug.write(DSESS, "checking response if it's what we expected."); if (pdu.getCommandId() != expResponse.getCommandId()) { debug.write(DSESS, "Got different response than expected " + expResponse.debugString()); if (pdu.getCommandId() == Data.GENERIC_NACK) {
if (pdu.getCommandId() == Data.OUTBIND) { debug.write("Got outbind PDU, sending event info. " + pdu.debugString()); sendOutbindEvent(new OutbindEvent(this, connection, (Outbind) pdu));