public MessageOutputStream writeMessage() throws IOException { int tries = 50; IntIndexMap<OutboundMessage> outboundMessages = this.outboundMessages; openOutboundMessage(); boolean ok = false; try { final Random random = ThreadLocalRandom.current(); while (tries > 0) { final int id = random.nextInt() & 0xfffe; if (! outboundMessages.containsKey(id)) { OutboundMessage message = new OutboundMessage((short) id, this, outboundWindow, maxOutboundMessageSize); OutboundMessage existing = outboundMessages.putIfAbsent(message); if (existing == null) { ok = true; return message; } } tries --; } throw log.channelBusy(); } finally { if (! ok) { closeOutboundMessage(); } } }
msg = new OutboundMessage("+00123456567889", "Hello from SMSLib!"); here replace +00123456567889 with +<your number with ISD code>
String message1 = url; OutboundMessage msg = new OutboundMessage("mygroup", message1); Service.getInstance().sendMessage(msg); System.out.println(msg); Service.getInstance().stopService(); Service.getInstance().removeGateway(gateway);//remove the gateway
OutboundMessage msg = new OutboundMessage("+94123456789", "SMS test: sample message from StackOverflow"); msg.setFrom("chandpriyankara");
OutboundMessage msg = new OutboundMessage(number, text); Service.getInstance().sendMessage(msg); System.out.println(msg);
OutboundMessage msg = new OutboundMessage("+94123456789", "SMS test: sample message from StackOverflow");
public MessageOutputStream writeMessage() throws IOException { int tries = 50; IntIndexMap<OutboundMessage> outboundMessages = this.outboundMessages; openOutboundMessage(); boolean ok = false; try { final Random random = ProtocolUtils.randomHolder.get(); while (tries > 0) { final int id = random.nextInt() & 0xfffe; if (! outboundMessages.containsKey(id)) { OutboundMessage message = new OutboundMessage((short) id, this, outboundWindow, maxOutboundMessageSize); OutboundMessage existing = outboundMessages.putIfAbsent(message); if (existing == null) { ok = true; return message; } } tries --; } throw log.channelBusy(); } finally { if (! ok) { closeOutboundMessage(); } } }
public MessageOutputStream writeMessage() throws IOException { int tries = 50; IntIndexMap<OutboundMessage> outboundMessages = this.outboundMessages; openOutboundMessage(); boolean ok = false; try { final Random random = ThreadLocalRandom.current(); while (tries > 0) { final int id = random.nextInt() & 0xfffe; if (! outboundMessages.containsKey(id)) { OutboundMessage message = new OutboundMessage((short) id, this, outboundWindow, maxOutboundMessageSize); OutboundMessage existing = outboundMessages.putIfAbsent(message); if (existing == null) { ok = true; return message; } } tries --; } throw log.channelBusy(); } finally { if (! ok) { closeOutboundMessage(); } } }