我正在使用 SMSLib v4 在 IP 模式下与 GSM 网关进行通信。我成功发送和接收消息,但问题在于传递消息。在使用 Diaffan SMS Server 进行测试后,我发现当使用国际格式(例如 +98 ...... 我设置了选项,使它们中的 PDU 变得相同。但是钢没有在我的应用程序中收到交货。
我的代码是:
public class TestIPModem
{
public String RECIPIENT1 = "+98...";
public String message = "salam";
public int count = 1;
public class InboundMessageCallback implements IInboundMessageCallback
{
@Override
public boolean process(InboundMessageCallbackEvent event)
{
if(event.getMessage().getType() == Type.Inbound){
System.out.println(event.getMessage().getPayload().getText());
}else if (event.getMessage().getType() == Type.StatusReport){
System.out.println(event.getMessage().getPayload().getText() + "Delivery");
}
return true;
}
}
public class DeliveryReportCallback implements IDeliveryReportCallback
{
@Override
public boolean process(DeliveryReportCallbackEvent event)
{
System.out.println("[DeliveryReportCallback] " + event.getMessage().toShortString());
System.out.println(event.getMessage().toString());
return true;
}
}
public void test() throws Exception
{
{
Settings.deleteMessagesAfterCallback = true;
Settings.modemPollingInterval = 100;
Service.getInstance().setInboundMessageCallback(new InboundMessageCallback());
Service.getInstance().setDeliveryReportCallback(new DeliveryReportCallback());
Service.getInstance().start();
Modem gateway1 = new Modem("modem1", "192.168.2.77", "9101", "0000", "0000", "+989350001400", "SM");
gateway1.setRequestDeliveryReport(true);
Service.getInstance().registerGateway(gateway1);
new Sender(1,count, RECIPIENT1, message, gateway1).start();
}
}
public class Sender implements Runnable{
int number;
int count;
String receiver;
String message;
Modem modem;
public Sender(int number, int count, String receiver, String message, Modem m) {
this.number = number;
this.count = count;
this.receiver = receiver;
this.message = "";
this.modem = m;
}
@Override
public void run() {
int i = 0;
while(i < this.count){
try {
OutboundMessage m = new OutboundMessage(this.receiver, this.messager);
m.setRequestDeliveryReport(true);
try {
modem.send(m);
} catch (Exception e) {
e.printStackTrace();
}
Thread.currentThread();
Thread.sleep(10);
i++;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) throws Exception {
new Thread(new Runnable() {
@Override
public void run() {
while(true){
try {
Thread.currentThread();
Thread.sleep(100000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
new TestIPModem().test();
}
}
那么你认为问题出在哪里?
更新:他们说 SMSLib 不支持 +CDS 交付报告。