SMSLIB Send Bulk Message on Multiple PhoneNumbers?

105 Views Asked by At

PROBLEM: how can my project spend less time by sending multiple messages in every client in my client list?

This is my SMS CLASS:

  public void sendSMS(String port, String phoneNumber, String message) throws Exception {

                try {
        OutboundNotification outboundNotification = new OutboundNotification();
        SerialModemGateway gateway = new SerialModemGateway("", port, 9600, "", "");
        gateway.setInbound(true);
        gateway.setOutbound(true);
        //gateway.setSimPin("0000");
        Service.getInstance().setOutboundMessageNotification(outboundNotification);
        Service.getInstance().addGateway(gateway);
         Service.getInstance().startService();
        OutboundMessage msg = new OutboundMessage(phoneNumber, message);
        Service.getInstance().sendMessage(msg);
        Service.getInstance().stopService();
        Service.getInstance().removeGateway(gateway);
        } catch (Exception ex) {
                    System.err.println("test");    
                    Logger.getLogger(SMS.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

This is how my code flows when i run i call sendsms.class in another class

for (Client client1 : client) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    String num = "";
                    num = client1.getPhonenumber().trim(); 
                    new SMS().sendSMS("COM7",num, taMessageFilter.getText());
                } catch (Exception ex) {
                    new PopupError().text(ex.getMessage());
                }
            }
        });
        t.start();
        try {
            Thread.sleep(20000);
        } catch (InterruptedException ex) {
            Logger.getLogger(Dsms.class.getName()).log(Level.SEVERE, null, ex);
        }

}
0

There are 0 best solutions below