📄 cmppconnection.java
字号:
}
cmpp_sm.setCommandId(CmppConstants.Cmpp_Active_Resp);
send(cmpp_sm);
break;
case CmppConstants.Cmpp_Active_Resp:
break;
case CmppConstants.Cmpp_Nack_Resp:
break;
default:
LogManage.ins().myLog.logp(Level.INFO, "", "", myBindType
+ " Recv Nack Command ");
// cmpp_sm.setCommandId(CmppConstants.Cmpp_Nack_Resp) ;
// cmpp_sm.setHeadCmdStatus(CmppConstants.error_command_id) ;
// send(cmpp_sm) ;
break;
}
}
public void disconnect() {
mystate = ComConstants.NOTCONNECTED;
try {
myinputstream.close();
} catch (Exception e) {
}
;
try {
myoutputstream.close();
} catch (Exception e) {
}
;
try {
mySocket.close();
} catch (Exception e) {
}
;
}
public void Login() {
LogManage.ins().myLog.logp(Level.INFO, "", "", myBindType
+ " CNGP loging . . . ");
ShortMsgCmpp cmpp_sm = new ShortMsgCmpp();
cmpp_sm.setConSourceAddr();
cmpp_sm.setCommandId(CmppConstants.Cmpp_Login);
cmpp_sm.setBindType(myBindType);
mystate = ComConstants.NOTLOGIN;
send(cmpp_sm);
myMBEauth = cmpp_sm.getConAuth();
mylastactivetime = System.currentTimeMillis();
}
public void submitLogout() {
ShortMsgCmpp cmpp_sm = new ShortMsgCmpp();
cmpp_sm.setCommandId(CmppConstants.Cmpp_Logout);
send(cmpp_sm);
}
private boolean heartBeat() {
ShortMsgCmpp cmpp_sm = new ShortMsgCmpp();
cmpp_sm.setCommandId(CmppConstants.Cmpp_Active);
if (ComConstants.mo_number >= 100000000)
ComConstants.mo_number = 1;
else
ComConstants.mo_number++;
send(cmpp_sm);
return true;
}
public void setLastVersion(byte i) {
myLastVersion = i;
}
public byte getLastVersion() {
return myLastVersion;
}
public String getStatus() {
return mystate;
}
public boolean addCmppMsg(ShortMsgCmpp cmppMsg) {
try {
// if(vcmppMsg1.size()+vcmppMsg2.size() >
// (ComConstants.CmppVECTOR_NUM-10) )
// return false;
if (vcmppMsgFlag == 1) {
vcmppMsg1.add(cmppMsg);
} else {
vcmppMsg2.add(cmppMsg);
}
return true;
} catch (Exception e) {
return false;
}
}
public int getNotDealMsgNum() {
try {
return vcmppMsg1.size() + vcmppMsg2.size();
} catch (Exception e) {
return -1;
}
}
public int getNotSubmitMsgNum() {
try {
return vCmppSubmitMsg.size();
} catch (Exception e) {
return -1;
}
}
private void handleCmppMsg(ShortMsgCmpp cmpp_sm) {
int unPackCode = CmppConstants.error;
boolean sendToSmsc = true;
switch (cmpp_sm.getCommandId()) {
case CmppConstants.Cmpp_Submit_Resp:
synchronized (vCmppSubmitMsg) {
for (int i = 0; i < vCmppSubmitMsg.size(); i++) {
try {
if (cmpp_sm.headSeqcNo == ((ShortMsgCmpp) vCmppSubmitMsg
.elementAt(i)).headSeqcNo) {
((ShortMsgCmpp) vCmppSubmitMsg.elementAt(i)).submit_msg_id_tem = cmpp_sm.submit_msg_id_tem;
if (cmpp_sm.activeResult != 8) {
((ShortMsgCmpp) vCmppSubmitMsg.elementAt(i)).headCmdStatus = (int) cmpp_sm.activeResult;
// CmppSaveLog.getIns().savesgipSubmitMsg((ShortMsgCmpp)vCmppSubmitMsg.elementAt(i));
CmppConnectionManager.instance().saveCmppData
.saveCmppSubmitMsg((ShortMsgCmpp) vCmppSubmitMsg
.elementAt(i));
// {
// PublicConstants.writeLog.info("have save a
// submit Msg Fualt!",0);
// }
vCmppSubmitMsg.remove(i);
} else {
((ShortMsgCmpp) vCmppSubmitMsg.elementAt(i)).headCmdStatus = (int) cmpp_sm.activeResult;
}
break;
}
} catch (Exception e) {
}
}
}
break;
case CmppConstants.Cmpp_Deliver:
if (cmpp_sm.msgMode == 1) {
TestReportnum++;
CmppConnectionManager.instance().saveCmppData
.saveCmppReportMsg(cmpp_sm);
// {
// PublicConstants.writeLog.info("Save Cmpp_Report
// erro"+cmpp_sm.msgSrcAddr,0);
// }
} else {
// CmppSaveLog.getIns() .savesgipDeliverMsg(cmpp_sm);
CmppConnectionManager.instance().saveCmppData
.saveCmppDeliverMsg(cmpp_sm);
// {
// PublicConstants.writeLog.info("Save Delieve Msg
// erro"+cmpp_sm.msgSrcAddr,0);
// }
}
break;
}
}
public void handleMsgThread() {
Runnable r = new Runnable() {
public void run() {
ShortMsgCmpp cmpp_sm = null;
while (!myShutdownFlag) {
try {
if (vcmppMsgFlag == 1) {
for (int i = 0; i < vcmppMsg2.size(); i++) {
try {
cmpp_sm = (ShortMsgCmpp) vcmppMsg2
.elementAt(i);
handleCmppMsg(cmpp_sm);
} catch (Exception e) {
}
}
if (vcmppMsg2.size() > 0)
vcmppMsg2.removeAllElements();
PublicFuction.threadSleep(500);
if (vcmppMsg1.size() <= 0)
PublicFuction.threadSleep(1000);
vcmppMsgFlag = 2;
} else {
for (int i = 0; i < vcmppMsg1.size(); i++) {
try {
cmpp_sm = (ShortMsgCmpp) vcmppMsg1
.elementAt(i);
handleCmppMsg(cmpp_sm);
} catch (Exception e) {
}
}
if (vcmppMsg1.size() > 0)
vcmppMsg1.removeAllElements();
PublicFuction.threadSleep(500);
if (vcmppMsg2.size() <= 0)
PublicFuction.threadSleep(1000);
vcmppMsgFlag = 1;
}
} catch (Exception e) {
}
}
LogManage.ins().myLog.severe(myBindType
+ " Handle Thread exit! ! ! ");
}
};
readVectorThread = new Thread(r);
readVectorThread.start();
}
private static ShortMsgCmpp deliverRespSM = new ShortMsgCmpp();
private long mylastactivetime;
private boolean myShutdownFlag = false;
private boolean myDelFlag = false;
private String mystate;
private String myip;
private int myport;
private Socket mySocket;
private InputStream myinputstream;
private OutputStream myoutputstream;
public DataInputStream dataInStream;
private Object _lock = new Object();
private byte myLastVersion;
private byte myBindType;
private byte myConnType;
private byte[] myMBEauth;
private String spIP;
private volatile Vector vcmppMsg1 = null;
private volatile Vector vcmppMsg2 = null;
private volatile Vector vCmppSubmitMsg = null;
private int vcmppMsgFlag;
private Thread resendThread;
private Thread readVectorThread;
public int mysign = 0;
private volatile static int TestMOnum = 0;
private volatile static int TestMOnum1 = 0;
private volatile static int TestReportnum = 0;
private volatile static int TestMTnum = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -