Package org.jsmpp.session

Examples of org.jsmpp.session.SMPPSession$BoundSessionStateListener


    String sourceMsisdn = "1616";
    String destinationMsisdn = "666111222";
    MessageClass messageClass = MessageClass.CLASS1;
    String messageBody = "Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula. Ut molestie a, ultricies porta urna.";

    SMPPSession session = new SMPPSession();
    session.addSessionStateListener(new SessionStateListenerImpl());
    session.setMessageReceiverListener(new MessageReceiverListenerImpl());

    try {
      session.connectAndBind("localhost", 2775, new BindParameter(BindType.BIND_TRX, "smppclient", "password",
          "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null));
    } catch (IOException e) {
      System.err.println("Failed connect and bind to host");
      e.printStackTrace();
    }

    // configure variables acording to if message contains national
    // characters
    Alphabet alphabet = null;
    int maximumSingleMessageSize = 0;
    int maximumMultipartMessageSegmentSize = 0;
    byte[] byteSingleMessage = null;
    if (Gsm0338.isEncodeableInGsm0338(messageBody)) {
      byteSingleMessage = messageBody.getBytes();
      alphabet = Alphabet.ALPHA_DEFAULT;
      maximumSingleMessageSize = MAX_SINGLE_MSG_SEGMENT_SIZE_7BIT;
      maximumMultipartMessageSegmentSize = MAX_MULTIPART_MSG_SEGMENT_SIZE_7BIT;
    } else {
      byteSingleMessage = messageBody.getBytes("UTF-16BE");
      alphabet = Alphabet.ALPHA_UCS2;
      maximumSingleMessageSize = MAX_SINGLE_MSG_SEGMENT_SIZE_UCS2;
      maximumMultipartMessageSegmentSize = MAX_MULTIPART_MSG_SEGMENT_SIZE_UCS2;
    }

    // check if message needs splitting and set required sending parameters
    byte[][] byteMessagesArray = null;
    ESMClass esmClass = null;
    if (messageBody.length() > maximumSingleMessageSize) {
      // split message according to the maximum length of a segment
      byteMessagesArray = splitUnicodeMessage(byteSingleMessage, maximumMultipartMessageSegmentSize);
      // set UDHI so PDU will decode the header
      esmClass = new ESMClass(MessageMode.DEFAULT, MessageType.DEFAULT, GSMSpecificFeature.UDHI);
    } else {
      byteMessagesArray = new byte[][] { byteSingleMessage };
      esmClass = new ESMClass();
    }

    System.out.println("Sending message " + messageBody);
    System.out.printf("Message is %d characters long and will be sent as %d messages with params: %s %s ",
        messageBody.length(), byteMessagesArray.length, alphabet, messageClass);
    System.out.println();

    // submit all messages
    for (int i = 0; i < byteMessagesArray.length; i++) {
      String messageId = submitMessage(session, byteMessagesArray[i], sourceMsisdn, destinationMsisdn,
          messageClass, alphabet, esmClass);
      System.out.println("Message submitted, message_id is " + messageId);
    }

    System.out.println("Entering listening mode. Press enter to finish...");

    try {
      System.in.read();
    } catch (IOException e) {
      e.printStackTrace();
    }

    session.unbindAndClose();
  }
View Full Code Here


     *
     * @return the {@link SMPPSession}.
     * @throws IOException if the creation of new session failed.
     */
    private SMPPSession newSession() throws IOException {
        SMPPSession tmpSession = new SMPPSession(remoteIpAddress, remotePort, bindParam);
        tmpSession.addSessionStateListener(new SessionStateListenerImpl());
        return tmpSession;
    }
View Full Code Here

    }
   
    private SMPPSession createSession() throws IOException {
        LOG.debug("Connecting to: " + getEndpoint().getConnectionString() + "...");
       
        SMPPSession session = createSMPPSession();
        session.setEnquireLinkTimer(this.configuration.getEnquireLinkTimer());
        session.setTransactionTimer(this.configuration.getTransactionTimer());
        session.addSessionStateListener(internalSessionStateListener);
        session.connectAndBind(
                this.configuration.getHost(),
                this.configuration.getPort(),
                new BindParameter(
                        BindType.BIND_TX,
                        this.configuration.getSystemId(),
View Full Code Here

     * Factory method to easily instantiate a mock SMPPSession
     *
     * @return the SMPPSession
     */
    SMPPSession createSMPPSession() {
        return new SMPPSession(new SynchronizedPDUSender(new DefaultPDUSender(
                new DefaultComposer())), new DefaultPDUReader(), SmppConnectionFactory
                .getInstance(configuration));
    }
View Full Code Here

    private SmppConfiguration config = new SmppConfiguration();
    private AbstractSmppCommand command;
   
    @Before
    public void setUp() {
        session = new SMPPSession();
        config = new SmppConfiguration();
       
        command = new AbstractSmppCommand(session, config) {
            @Override
            public void execute(Exchange exchange) throws SmppException {
View Full Code Here

        assertSame(configuration, binding.getConfiguration());
    }
   
    @Test
    public void createSmppSubmitSmCommand() {
        SMPPSession session = new SMPPSession();
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
       
        SmppCommand command = binding.createSmppCommand(session, exchange);
       
        assertTrue(command instanceof SmppSubmitSmCommand);
View Full Code Here

        assertTrue(command instanceof SmppSubmitSmCommand);
    }
   
    @Test
    public void createSmppSubmitMultiCommand() {
        SMPPSession session = new SMPPSession();
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
       
        SmppCommand command = binding.createSmppCommand(session, exchange);
       
View Full Code Here

        assertTrue(command instanceof SmppSubmitMultiCommand);
    }
   
    @Test
    public void createSmppDataSmCommand() {
        SMPPSession session = new SMPPSession();
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.getIn().setHeader(SmppConstants.COMMAND, "DataSm");
       
        SmppCommand command = binding.createSmppCommand(session, exchange);
       
View Full Code Here

        assertTrue(command instanceof SmppDataSmCommand);
    }
   
    @Test
    public void createSmppReplaceSmCommand() {
        SMPPSession session = new SMPPSession();
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.getIn().setHeader(SmppConstants.COMMAND, "ReplaceSm");
       
        SmppCommand command = binding.createSmppCommand(session, exchange);
       
View Full Code Here

        assertTrue(command instanceof SmppReplaceSmCommand);
    }
   
    @Test
    public void createSmppQuerySmCommand() {
        SMPPSession session = new SMPPSession();
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.getIn().setHeader(SmppConstants.COMMAND, "QuerySm");
       
        SmppCommand command = binding.createSmppCommand(session, exchange);
       
View Full Code Here

TOP

Related Classes of org.jsmpp.session.SMPPSession$BoundSessionStateListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.