コード例 #1
0
 public SmppSessionConfiguration createDefaultConfiguration() {
   SmppSessionConfiguration configuration = new SmppSessionConfiguration();
   configuration.setWindowSize(1);
   configuration.setName("Tester.Session.0");
   configuration.setType(SmppBindType.TRANSCEIVER);
   configuration.setHost("localhost");
   configuration.setPort(PORT);
   configuration.setConnectTimeout(100);
   configuration.setBindTimeout(100);
   configuration.setSystemId(SYSTEMID);
   configuration.setPassword(PASSWORD);
   configuration.getLoggingOptions().setLogBytes(true);
   return configuration;
 }
コード例 #2
0
  protected void createSession(
      Long sessionId,
      Channel channel,
      SmppSessionConfiguration config,
      BaseBindResp preparedBindResponse)
      throws SmppProcessingException {
    // NOTE: exactly one PDU (bind request) was read from the channel, we
    // now need to delegate permitting this bind request by calling a method
    // further upstream.  Only after the server-side is completely ready to
    // start processing requests from this session, do we want to actually
    // return the bind response and start reading further requests -- we'll
    // initially block reading from the channel first -- this will be turned
    // back on via the "serverReady()" method call on the session object

    // make sure the channel is not being read/processed (until we flag we're ready later on)
    channel.config().setAutoRead(false);

    // auto negotiate the interface version in use based on the requested interface version
    byte interfaceVersion = this.autoNegotiateInterfaceVersion(config.getInterfaceVersion());

    // create a new server session associated with this server
    DefaultSmppSession session =
        new DefaultSmppSession(
            SmppSession.Type.SERVER,
            config,
            channel,
            this,
            sessionId,
            preparedBindResponse,
            interfaceVersion,
            monitorExecutor);

    // replace name of thread used for renaming
    SmppSessionThreadRenamer threadRenamer =
        (SmppSessionThreadRenamer)
            channel.pipeline().get(SmppChannelConstants.PIPELINE_SESSION_THREAD_RENAMER_NAME);
    threadRenamer.setThreadName(config.getName());

    // add a logging handler after the thread renamer
    SmppSessionLogger loggingHandler =
        new SmppSessionLogger(
            DefaultSmppSession.class.getCanonicalName(), config.getLoggingOptions());
    channel
        .pipeline()
        .addAfter(
            SmppChannelConstants.PIPELINE_SESSION_THREAD_RENAMER_NAME,
            SmppChannelConstants.PIPELINE_SESSION_LOGGER_NAME,
            loggingHandler);

    // decoder in pipeline is ok (keep it)

    // create a new wrapper around a session to pass the pdu up the chain
    channel.pipeline().remove(SmppChannelConstants.PIPELINE_SESSION_WRAPPER_NAME);
    channel
        .pipeline()
        .addLast(
            SmppChannelConstants.PIPELINE_SESSION_WRAPPER_NAME, new SmppSessionWrapper(session));

    // check if the # of channels exceeds maxConnections
    if (this.channels.size() > this.configuration.getMaxConnectionSize()) {
      logger.warn(
          "The current connection size [{}] exceeds the configured max connection size [{}]",
          this.channels.size(),
          this.configuration.getMaxConnectionSize());
    }

    // session created, now pass it upstream
    counters.incrementSessionCreatedAndGet();
    incrementSessionSizeCounters(session);
    this.serverHandler.sessionCreated(sessionId, session, preparedBindResponse);

    // register this session as an mbean
    if (configuration.isJmxEnabled()) {
      session.registerMBean(
          configuration.getJmxDomain()
              + ":type="
              + configuration.getName()
              + "Sessions,name="
              + sessionId);
    }
  }