📄 smsmain.java
字号:
package com.gctech.sms.sp.dwzb;
import org.apache.log4j.*;
import com.gctech.sms.sp.cms.core.*;
import com.gctech.sms.sp.cms.msg.*;
/**
* 主程序入口,将从平台接收短消息信息并做处理
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: gctech</p>
* @author lijz@gctech.com.cn
* @version 1.0
*/
public class SMSMain
{
static Logger logger = Logger.getLogger(SMSMain.class);
PlatformAPI pfa = null;
SessionFactory sf = null;
static SMSMain smsMain = new SMSMain();
private SMSMain()
{
}
public static SMSMain instance()
{
return smsMain;
}
public void start() throws Exception
{
logger.info("SMS SERVICE START.......");
sf = new SessionFactory(Config.instance().getSessionMax(),Config.instance().getTTL());
pfa = new PlatformAPI(Config.instance().getPlatformIP(),
Config.instance().getPlatformPort());
pfa.addRecevierListener(new DWZBListener(pfa,sf));
//edit by liyi , add yuyin part
pfa.addRecevierListener(new YYDXListener(pfa,sf));
int status = pfa.login(Config.instance().getSpId(),
Config.instance().getSecret());
if(status != 0)
{
logger.info("连接平台失败!Exit");
throw new Exception("连接平台失败!Exit");
}
else
{
System.out.println("SMS SERVICE START OK");
}
}
public boolean sendMessage(String phone,String content)
{
// return true;
SubmitMessage sm = new SubmitMessage(Config.instance().getSpId(),
Config.instance().getFreeFeeServiceId(),content,phone,phone,"");
try
{
pfa.addMessage(sm);
return true;
}
catch(Exception ex)
{
return false;
}
}
public void colse()
{
pfa.logout();
sf.clear();
logger.info("SMS SERVICE CLOSED");
}
public static void main(String[] args) throws Exception
{
SMSMain main = new SMSMain();
main.start();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -