Package com.cloudhopper.smpp

Examples of com.cloudhopper.smpp.SmppSession


        sessionConfig0.setBindTimeout(30000);

        long start = System.currentTimeMillis();
        try {
            // this should fail
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.fail();
        } catch (SmppChannelException e) {
            long stop = System.currentTimeMillis();
            Assert.assertNotNull(e);
            logger.info("Expected exception: " + e.getMessage());
View Full Code Here


        sessionConfig0.setConnectTimeout(30000);
        sessionConfig0.setBindTimeout(30000);
        long start = System.currentTimeMillis();
        try {
            // this should fail
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.fail();
        } catch (SmppChannelException e) {
            long stop = System.currentTimeMillis();
            Assert.assertNotNull(e);
            logger.info("Expected exception: " + e.getMessage());
View Full Code Here

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();

        try {
            // this should actually work
            SmppSession session0 = client0.bind(sessionConfig0);
            Thread.sleep(200);

            Assert.assertEquals(1, serverHandler.sessions.size());
            Assert.assertEquals(1, server0.getChannels().size());
View Full Code Here

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();

        try {
            SmppSession session0 = client0.bind(sessionConfig0);
            Thread.sleep(100);

            // send encrypted enquire link; receive encrypted response.
            EnquireLinkResp enquireLinkResp = session0.enquireLink(new EnquireLink(), 1000);

            Assert.assertEquals(0, enquireLinkResp.getCommandStatus());
            Assert.assertEquals("OK", enquireLinkResp.getResultMessage());
        } finally {
            server0.destroy();
View Full Code Here

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationStrongSSL();

        try {
            // this should work
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.assertNotNull(session0);
        } catch (Exception e) {
            Assert.fail();
        } finally {
            server0.destroy();
View Full Code Here

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();
        try {
            // this should fail
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.fail();
        } catch (Exception e) {
            Assert.assertNotNull(e);
            logger.info("Expected exception: " + e.getMessage());
        } finally {
View Full Code Here

  config0.setUseSsl(true);

        //
        // create session, enquire link, submit an sms, close session
        //
        SmppSession session0 = null;

        try {
            // create session a session by having the bootstrap connect a
            // socket, send the bind request, and wait for a bind response
            session0 = clientBootstrap.bind(config0, sessionHandler);
           
            System.out.println("Press any key to send enquireLink #1");
            System.in.read();

            // demo of a "synchronous" enquireLink call - send it and wait for a response
            EnquireLinkResp enquireLinkResp1 = session0.enquireLink(new EnquireLink(), 10000);
            logger.info("enquire_link_resp #1: commandStatus [" + enquireLinkResp1.getCommandStatus() + "=" + enquireLinkResp1.getResultMessage() + "]");
           
            System.out.println("Press any key to send enquireLink #2");
            System.in.read();

            // demo of an "asynchronous" enquireLink call - send it, get a future,
            // and then optionally choose to pick when we wait for it
            WindowFuture<Integer,PduRequest,PduResponse> future0 = session0.sendRequestPdu(new EnquireLink(), 10000, true);
            if (!future0.await()) {
                logger.error("Failed to receive enquire_link_resp within specified time");
            } else if (future0.isSuccess()) {
                EnquireLinkResp enquireLinkResp2 = (EnquireLinkResp)future0.getResponse();
                logger.info("enquire_link_resp #2: commandStatus [" + enquireLinkResp2.getCommandStatus() + "=" + enquireLinkResp2.getResultMessage() + "]");
            } else {
                logger.error("Failed to properly receive enquire_link_resp: " + future0.getCause());
            }

            System.out.println("Press any key to send submit #1");
            System.in.read();

            String text160 = "\u20AC Lorem [ipsum] dolor sit amet, consectetur adipiscing elit. Proin feugiat, leo id commodo tincidunt, nibh diam ornare est, vitae accumsan risus lacus sed sem metus.";
            byte[] textBytes = CharsetUtil.encode(text160, CharsetUtil.CHARSET_GSM);
           
            SubmitSm submit0 = new SubmitSm();

            // add delivery receipt
            //submit0.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED);

            submit0.setSourceAddress(new Address((byte)0x03, (byte)0x00, "40404"));
            submit0.setDestAddress(new Address((byte)0x01, (byte)0x01, "44555519205"));
            submit0.setShortMessage(textBytes);

            SubmitSmResp submitResp = session0.submit(submit0, 10000);
           
           
            logger.info("sendWindow.size: {}", session0.getSendWindow().getSize());
           
            System.out.println("Press any key to unbind and close sessions");
            System.in.read();
           
            session0.unbind(5000);
        } catch (Exception e) {
            logger.error("", e);
        }

        if (session0 != null) {
            logger.info("Cleaning up session... (final counters)");
            if (session0.hasCounters()) {
                logger.info("tx-enquireLink: {}", session0.getCounters().getTxEnquireLink());
                logger.info("tx-submitSM: {}", session0.getCounters().getTxSubmitSM());
                logger.info("tx-deliverSM: {}", session0.getCounters().getTxDeliverSM());
                logger.info("tx-dataSM: {}", session0.getCounters().getTxDataSM());
                logger.info("rx-enquireLink: {}", session0.getCounters().getRxEnquireLink());
                logger.info("rx-submitSM: {}", session0.getCounters().getRxSubmitSM());
                logger.info("rx-deliverSM: {}", session0.getCounters().getRxDeliverSM());
                logger.info("rx-dataSM: {}", session0.getCounters().getRxDataSM());
            }
           
            session0.destroy();
            // alternatively, could call close(), get outstanding requests from
            // the sendWindow (if we wanted to retry them later), then call shutdown()
        }

        // this is required to not causing server to hang from non-daemon threads
View Full Code Here

            this.sessionRef = new WeakReference<SmppSession>(session);
        }
       
        @Override
        public PduResponse firePduRequestReceived(PduRequest pduRequest) {
            SmppSession session = sessionRef.get();
           
            // mimic how long processing could take on a slower smsc
            try {
                //Thread.sleep(50);
            } catch (Exception e) { }
View Full Code Here

        try {
            DefaultSmppClient client0 = new DefaultSmppClient();
            SmppSessionConfiguration sessionConfig0 = createDefaultConfiguration();
            // this should actually work
            SmppSession session0 = client0.bind(sessionConfig0);

            Thread.sleep(100);

            SmppServerSession serverSession0 = serverHandler.sessions.iterator().next();
            Assert.assertEquals(1, serverHandler.sessions.size());
View Full Code Here

            SmppSessionConfiguration sessionConfig0 = createDefaultConfiguration();
            sessionConfig0.setSystemId("TESTID");

            // this should fail (invalid system id)
            try {
                SmppSession session0 = client0.bind(sessionConfig0);
                Assert.fail();
            } catch (SmppBindException e) {
                Assert.assertEquals(SmppConstants.STATUS_INVSYSID, e.getBindResponse().getCommandStatus());
            }
View Full Code Here

TOP

Related Classes of com.cloudhopper.smpp.SmppSession

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.