SieuHoTro.Com
 
Home My Account Register Domain Transfer Domain Contact Us Whois Documentation
 
Forum Home Forum Home > Information Technology > The programming language > Java, Java script
  New Posts New Posts RSS Feed: package sms.gateway.process
  FAQ FAQ  Forum Search   Register Register  Login Login
If this is your first visit, be sure to check out theForum by clicking the link above. You may have toregister before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
ASG Vietnam

package sms.gateway.process

 Post Reply Post Reply
Author
admingroup View Drop Down
Admin
Admin

ad

Joined: 14 October 2005
Online Status: Offline
Posts: 508
  Quote admingroup Quote  Post ReplyReply Direct Link To This Post Topic: package sms.gateway.process
    Posted: 16 April 2009 at 21:12

package sms.gateway.process;

 
import smpp.*;
import smpp.pdu.*;

import sms.util.Queue;
import sms.util.FileTool;
import sms.common.*;
import sms.gateway.Gateway;
import java.io.IOException;

/**
 * For receiving PDUs from SMSC, in Sync mode
 * --> Only request PDUs are received.
 */
public class SMPPReceiver extends Thread {
    private static Logger logger = new Logger("SMPPReceiver");

    private PDU pdu = null;
    private DeliverSM dsm = null;
    private Queue requestQueue = null;


    public SMPPReceiver() {
        this.requestQueue = Gateway.getRequestQueue();
    }
    public void run() {
        while (Gateway.isRunning()) {
            try {
                //pdu = Gateway.getSessionR().receive(Preference.receiveTimeout);
                pdu = Gateway.getSessionR().receive();
                if (pdu == null) continue;

                if (pdu.isValid()) {
                    if (pdu.isRequest()) {
                        // Logger.println2C("==> " + pdu.debugString());

                        // Make default response
                        Response response = ( (Request) pdu).getResponse();

                        // Reply with default response
                        //Logger.println2C("<== " + response.debugString());
                        Gateway.getSessionR().respond(response);

                        // Add to requestQueue for further processing
                        if (pdu.getCommandId() != Data.ENQUIRE_LINK) {
                            if (pdu.getCommandId() == Data.DELIVER_SM) {
                                dsm = (DeliverSM) pdu;
                                logger.printPDU(dsm);
                                requestQueue.enqueue(pdu);
                            } else {
                                logger.info("Not a Deliver_SM: " + pdu.debugString());
                            }
                        }
                    } else if (pdu.isResponse()) {
                        // Process response
                        if (pdu.getCommandId() == Data.UNBIND_RESP) {
                            UnbindResp response = (UnbindResp) pdu;
                            logger.info("Unbind response " + response.debugString());
                            Gateway.setBoundR(false);
                            //System.exit(0);
                        } else {
                            logger.info("received a response(?), while expect requests only.");
                        }
                    } else {
                        logger.info(
                            "pdu of unknown class (not request nor response) " +
                            "received; Discarding " + pdu.debugString());
                    }
                } else {
                    logger.info("Received an invalid pdu: " + pdu);
                    String filename = "" + System.currentTimeMillis() + "_inv_pdu.dat";
                    logger.info("-->Save to file: " + filename);
                    try {
                        FileTool.saveToFile(pdu.getData().getBuffer(), filename, false);
                    } catch (ValueNotSetException ex) {
                        logger.error("handleEvent: " + ex.getMessage());
                    }
                }
            } catch (IOException ex) {
                logger.alert("DISCONNECTED from SMSC.");
                if (Gateway.isBound()) {
                    Gateway.setBound(false);
                    Gateway.setBoundR(false);
                    Gateway.bind();
                }
            } catch (Exception ex) {
                logger.error("run: " + ex.getMessage());
            }
        }
    }
}


  Share Topic     
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.063 seconds.
[Free Express Edition]
Copyright ©2001-2009 Web Wiz
Support: raovatphanmem Support: Info hanoi software
Online(s): 53.
Visitors Counter:36962341, AVERAGE/day(3439) is: 10748
Begin count is day 02/16/2009

You are browsing this site with: CCBot/2.0 (http://commoncrawl.org/faq/)
Your IP address is: 23.20.223.212
The DNS lookup of the IP address is: 23.20.223.212
The method used to call the page: GET
The server's domain name: sieuhotro.com
The link
BaoKyNam Viêm gan b Thẩm mỹ viện Hoa Kỳ