コード例 #1
0
  @Override
  public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu)
      throws Exception {
    // anything other than a bind is super bad!
    if (!(pdu instanceof BaseBind)) {
      if (pdu instanceof PduRequest) {
        session.addPduToWriteOnNextPduReceived(
            ((PduRequest) pdu).createGenericNack(SmppConstants.STATUS_INVBNDSTS));
        return true;
      } else {
        // logger.error("PDU response received, but not bound");
        channel.close();
        return true;
      }
    }

    BaseBind bind = (BaseBind) pdu;
    BaseBindResp bindResp = (BaseBindResp) bind.createResponse();

    if (!bind.getSystemId().equals(systemId)) {
      bindResp.setCommandStatus(SmppConstants.STATUS_INVSYSID);
    } else if (!bind.getPassword().equals(password)) {
      bindResp.setCommandStatus(SmppConstants.STATUS_INVPASWD);
    }

    session.addPduToWriteOnNextPduReceived(bindResp);
    return true;
  }
コード例 #2
0
    @Override
    public void sessionBindRequested(
        Long sessionId, SmppSessionConfiguration sessionConfiguration, final BaseBind bindRequest)
        throws SmppProcessingException {
      // test name change of sessions
      sessionConfiguration.setName("Test1");

      if (!SYSTEMID.equals(bindRequest.getSystemId())) {
        throw new SmppProcessingException(SmppConstants.STATUS_INVSYSID);
      }

      if (!PASSWORD.equals(bindRequest.getPassword())) {
        throw new SmppProcessingException(SmppConstants.STATUS_INVPASWD);
      }

      // throw new SmppProcessingException(SmppConstants.STATUS_BINDFAIL, null);
    }