亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? autoreconnectgateway.java

?? JSMPP Examples to send and receive sms from java via smpp protocol.
?? JAVA
字號:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package org.jsmpp.examples.gateway;

import java.io.IOException;

import org.apache.log4j.BasicConfigurator;
import org.jsmpp.InvalidResponseException;
import org.jsmpp.PDUException;
import org.jsmpp.bean.BindType;
import org.jsmpp.bean.DataCoding;
import org.jsmpp.bean.ESMClass;
import org.jsmpp.bean.NumberingPlanIndicator;
import org.jsmpp.bean.OptionalParameter;
import org.jsmpp.bean.RegisteredDelivery;
import org.jsmpp.bean.TypeOfNumber;
import org.jsmpp.extra.NegativeResponseException;
import org.jsmpp.extra.ResponseTimeoutException;
import org.jsmpp.extra.SessionState;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.SMPPSession;
import org.jsmpp.session.SessionStateListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This are implementation of {@link Gateway}. This gateway will reconnect for a
 * specified interval if the session are closed.
 * 
 * @author uudashr
 * 
 */
public class AutoReconnectGateway implements Gateway {
    private static final Logger logger = LoggerFactory.getLogger(AutoReconnectGateway.class);
    private SMPPSession session = null;
    private String remoteIpAddress;
    private int remotePort;
    private BindParameter bindParam;
    private long reconnectInterval = 5000L; // 5 seconds

    /**
     * Construct auto reconnect gateway with specified ip address, port and SMPP
     * Bind parameters.
     * 
     * @param remoteIpAddress is the SMSC IP address.
     * @param remotePort is the SMSC port.
     * @param bindParam is the SMPP Bind parameters.
     * @throws IOException
     */
    public AutoReconnectGateway(String remoteIpAddress, int remotePort,
            BindParameter bindParam) throws IOException {
        this.remoteIpAddress = remoteIpAddress;
        this.remotePort = remotePort;
        this.bindParam = bindParam;
        session = newSession();
    }
    
    /* (non-Javadoc)
     * @see org.jsmpp.examples.gateway.Gateway#submitShortMessage(java.lang.String, org.jsmpp.bean.TypeOfNumber, org.jsmpp.bean.NumberingPlanIndicator, java.lang.String, org.jsmpp.bean.TypeOfNumber, org.jsmpp.bean.NumberingPlanIndicator, java.lang.String, org.jsmpp.bean.ESMClass, byte, byte, java.lang.String, java.lang.String, org.jsmpp.bean.RegisteredDelivery, byte, org.jsmpp.bean.DataCoding, byte, byte[], org.jsmpp.bean.OptionalParameter[])
     */
    public String submitShortMessage(String serviceType,
            TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi,
            String sourceAddr, TypeOfNumber destAddrTon,
            NumberingPlanIndicator destAddrNpi, String destinationAddr,
            ESMClass esmClass, byte protocolId, byte priorityFlag,
            String scheduleDeliveryTime, String validityPeriod,
            RegisteredDelivery registeredDelivery, byte replaceIfPresentFlag,
            DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage,
            OptionalParameter... optionalParameters) throws PDUException,
            ResponseTimeoutException, InvalidResponseException,
            NegativeResponseException, IOException {
        
        return getSession().submitShortMessage(serviceType, sourceAddrTon,
                sourceAddrNpi, sourceAddr, destAddrTon, destAddrNpi,
                destinationAddr, esmClass, protocolId, priorityFlag,
                scheduleDeliveryTime, validityPeriod, registeredDelivery,
                replaceIfPresentFlag, dataCoding, smDefaultMsgId, shortMessage,
                optionalParameters);
    }

    /**
     * Create new {@link SMPPSession} complete with the
     * {@link SessionStateListenerImpl}.
     * 
     * @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;
    }

    /**
     * Get the session. If the session still null or not in bound state, then IO
     * exception will be thrown.
     * 
     * @return the valid session.
     * @throws IOException if there is no valid session or session creation is
     *         invalid.
     */
    private SMPPSession getSession() throws IOException {
        if (session == null) {
            logger.info("Initiate session for the first time to " + remoteIpAddress + ":" + remotePort);
            session = newSession();
        } else if (!session.getSessionState().isBound()) {
            throw new IOException("We have no valid session yet");
        }
        return session;
    }
    
    /**
     * Reconnect session after specified interval.
     * 
     * @param timeInMillis is the interval.
     */
    private void reconnectAfter(final long timeInMillis) {
        new Thread() {
            @Override
            public void run() {
                logger.info("Schedule reconnect after " + timeInMillis + " millis");
                try {
                    Thread.sleep(timeInMillis);
                } catch (InterruptedException e) {
                }
                
                int attempt = 0;
                while (session == null || session.getSessionState().equals(SessionState.CLOSED)) {
                    try {
                        logger.info("Reconnecting attempt #" + (++attempt) + "...");
                        session = newSession();
                    } catch (IOException e) {
                        logger.error("Failed opening connection and bind to " + remoteIpAddress + ":" + remotePort, e);
                        // wait for a second
                        try { Thread.sleep(1000); } catch (InterruptedException ee) {}
                    }
                }
            }
        }.start();
    }

    /**
     * This class will receive the notification from {@link SMPPSession} for the
     * state changes. It will schedule to re-initialize session.
     * 
     * @author uudashr
     * 
     */
    private class SessionStateListenerImpl implements SessionStateListener {
        public void onStateChange(SessionState newState, SessionState oldState,
                Object source) {
            if (newState.equals(SessionState.CLOSED)) {
                logger.info("Session closed");
                reconnectAfter(reconnectInterval);
            }
        }
    }
    
    public static void main(String[] args) throws IOException {
        BasicConfigurator.configure();
        Gateway gateway = new AutoReconnectGateway("localhost", 8056, 
                new BindParameter(BindType.BIND_TRX, "sms", "sms", "sms", 
                        TypeOfNumber.UNKNOWN, NumberingPlanIndicator.ISDN, "8080"));
        
        while (true) {
            try { Thread.sleep(1000); } catch (InterruptedException e) {}
        }
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美一区二区视频| 成人听书哪个软件好| 国产一区二区三区蝌蚪| av不卡免费在线观看| 日韩欧美的一区二区| 一区二区免费视频| 成人激情动漫在线观看| 日韩欧美精品在线| 亚洲电影一级片| 91蝌蚪porny| 国产精品色哟哟| 国产一区二区看久久| 制服丝袜亚洲色图| 亚洲成人三级小说| 在线观看av一区二区| 国产精品乱码一区二三区小蝌蚪| 日本 国产 欧美色综合| 色偷偷88欧美精品久久久| 国产精品久久毛片av大全日韩| 蜜臀精品一区二区三区在线观看 | 一本一道波多野结衣一区二区| 日韩一区二区免费在线电影| 亚洲国产毛片aaaaa无费看| 99久久99久久精品免费观看 | 51久久夜色精品国产麻豆| 亚洲另类在线一区| 成人avav影音| 国产精品国产三级国产普通话蜜臀| 国产美女精品在线| 久久你懂得1024| 国产麻豆精品久久一二三| 欧美r级在线观看| 卡一卡二国产精品| 日韩久久免费av| 久久69国产一区二区蜜臀| 日韩欧美一级片| 国内一区二区在线| 久久一区二区视频| 国产成人av电影在线| 国产精品乱子久久久久| 色综合久久99| 首页综合国产亚洲丝袜| 日韩欧美123| 国产激情偷乱视频一区二区三区| 欧美国产日韩亚洲一区| 94色蜜桃网一区二区三区| 一区二区三区中文字幕在线观看| 欧美午夜电影在线播放| 日韩精品电影在线| 久久丝袜美腿综合| 正在播放亚洲一区| 久久国产精品第一页| 国产欧美日本一区视频| av一二三不卡影片| 亚洲成人免费在线观看| 日韩欧美一区二区在线视频| 国产激情视频一区二区三区欧美| 国产精品福利影院| 欧美日韩日本视频| 国产一本一道久久香蕉| 亚洲男人的天堂av| 91精品久久久久久蜜臀| 国产成人免费在线| 一区二区高清免费观看影视大全| 3d成人动漫网站| 国产·精品毛片| 亚洲成人久久影院| 欧美激情在线一区二区三区| 欧美写真视频网站| 国产一区视频网站| 亚洲123区在线观看| 久久奇米777| 在线91免费看| jvid福利写真一区二区三区| 日韩制服丝袜av| 《视频一区视频二区| 欧美一区二区三区电影| 99久久精品国产网站| 久久99深爱久久99精品| 亚洲狠狠丁香婷婷综合久久久| 精品国产乱码久久久久久久久| 欧洲一区在线观看| 成人天堂资源www在线| 日本最新不卡在线| 亚洲欧美另类小说| 国产视频一区在线播放| 91精品国产高清一区二区三区蜜臀 | 91福利国产成人精品照片| 久久www免费人成看片高清| 成人欧美一区二区三区白人 | 欧美亚洲精品一区| 成人黄色在线看| 精品一区二区三区视频| 亚洲成av人片在线| 国产精品久久久久影院亚瑟| 欧美成人性战久久| 欧美日本一道本| 一本色道久久综合狠狠躁的推荐| 国产一区二区福利视频| 免费在线看一区| 亚洲va在线va天堂| 亚洲国产精品一区二区www| 亚洲色图.com| 亚洲天堂中文字幕| 最近日韩中文字幕| 亚洲欧洲成人av每日更新| 国产午夜亚洲精品理论片色戒 | 一区精品在线播放| 国产精品久久久久久久久晋中| 久久新电视剧免费观看| 亚洲精品在线观看视频| 欧美成人r级一区二区三区| 日韩视频一区二区三区| 欧美老人xxxx18| 欧美精品久久久久久久多人混战| 欧美在线观看禁18| 欧美色男人天堂| 欧美久久久一区| 亚洲国产成人在线| 久久久久国产精品人| 久久久久久一二三区| 久久久99免费| 国产精品天美传媒沈樵| 中文字幕一区二区三区精华液| 国产精品国产自产拍高清av王其| 亚洲视频中文字幕| 亚洲图片有声小说| 午夜精品久久一牛影视| 日本欧美肥老太交大片| 久久se精品一区精品二区| 国产成人夜色高潮福利影视| 大桥未久av一区二区三区中文| av午夜精品一区二区三区| 91福利国产精品| 6080日韩午夜伦伦午夜伦| 精品国产在天天线2019| 亚洲国产高清在线| 亚洲一区二区在线免费观看视频| 亚洲成人av福利| 精品一区二区三区在线播放视频| 国产不卡一区视频| 在线看国产一区| 日韩欧美国产综合一区| 国产欧美久久久精品影院| 亚洲欧美日韩久久精品| 亚洲第一会所有码转帖| 国内外成人在线视频| 91亚洲永久精品| 日韩一区二区在线观看视频播放| 久久久噜噜噜久久中文字幕色伊伊| 国产精品久久久久久久蜜臀| 亚洲国产欧美在线| 国产精品资源在线观看| 91成人在线精品| 久久人人97超碰com| 亚洲免费电影在线| 极品少妇xxxx精品少妇| 色狠狠av一区二区三区| 久久久99免费| 午夜激情一区二区| 国产999精品久久久久久绿帽| 欧美日韩在线三区| 国产精品传媒入口麻豆| 麻豆精品国产传媒mv男同| 91麻豆免费看| 国产午夜精品一区二区三区视频| jiyouzz国产精品久久| 欧美日韩精品二区第二页| 国产午夜亚洲精品不卡| 五月激情综合色| 91一区在线观看| 国产亚洲欧美色| 免费在线观看精品| 91精彩视频在线| 中文字幕免费不卡| 麻豆成人免费电影| 欧美日韩三级一区二区| 亚洲少妇30p| 国产成人综合精品三级| 欧美一级久久久| 亚洲一区二区三区国产| 成人福利在线看| 26uuu另类欧美| 久久精品国产一区二区三| 欧美日韩免费电影| 亚洲欧美综合网| 成人黄色一级视频| 中文字幕精品一区二区三区精品| 久草精品在线观看| 日韩区在线观看| 美女mm1313爽爽久久久蜜臀| 欧美人伦禁忌dvd放荡欲情| 夜夜嗨av一区二区三区网页| 99精品久久免费看蜜臀剧情介绍| 国产香蕉久久精品综合网| 国产精品一区二区三区99| 精品免费国产一区二区三区四区| 日韩av二区在线播放| 91精品黄色片免费大全| 日本亚洲电影天堂|