Support of USSD in Logica OpenSMPP - java

I am using Logica OpenSMPP (http://opensmpp.org/) to manage messages via SMPP protocol. I have a server, which can answer on my SMS and USSD messages, and I am developing a client. I have already managed to send DeliverSM message and get SubmitSM response from server via SMS: first I start SMSC, and then do something like that:
DeliverSM request = new DeliverSM();
request.setSourceAddr(from);
request.setDestAddr(to);
try {
request.setShortMessage(message);
} catch (WrongLengthOfStringException e) {
log.error("Error during setShortMessage", e);
}
request.setRegisteredDelivery((byte) 0);
new Transmitter(this.connection).send(request);
But I encounter some problems while doing the same for USSD. I know, that I must somehow use the following (cut from SMPP V3.4 Specification):
The ussd_service_op parameter is required to define the USSD service
operation when SMPP is being used as an interface to a (GSM) USSD
system.
What are the steps that I need to do to learn my client send both SMS and USSD messages to server?

This project hosts code for sending USSD. You may consider browsing the code to see how it's done, and then implement similar features in Logica OpenSMPP.

Related

sns push notification publish to a single device

This is the code i found on SNS's official site to publish to a topic
String msg = "My text published to SNS topic with email endpoint";
PublishRequest publishRequest = new PublishRequest(topicArn, msg);
PublishResult publishResult = snsClient.publish(publishRequest);
System.out.println("MessageId - " + publishResult.getMessageId());
I am developing a chat app on for android using sns(it will also push notifications to the existing ios counterpart of the app)
if i want to publish to a single device directly can i give device's "ApplicationEndPointArn" instead of topicArn
SNS is intended to decouple notification service from application layer.
We could create a topic and add mobile endpoints as subscribers.
When a message is published to the topic all subscribers will get notified.
Apart from this if you would really need single endpoint messaging you could try,
PublishRequest publishRequest = new PublishRequest();
publishRequest.setTargetArn(endpointArn);
publishRequest.setMessage("SOME MESSAGE");
snsClient.publish(publishRequest)
where endpointArn is a device endpoint.
But make sure that you persist this device endpoint when device is registered in SNS and use the same returned EndpointArn for further communication.

Java websocket with proxy

I have been trying all day and night for couple of days trying to make websocket to work using proxy in Java. I tried different library like
https://github.com/TooTallNate/Java-WebSocket
https://github.com/AsyncHttpClient/async-http-client
But sadly these library doesn't support proxy with credentials. If you guys have known any other library that supports proxy then I would be appreciated.
Thanks in advance
Try nv-websocket-client library. It supports authentication at a proxy server. Note that, however, the current implementation supports Basic Authentication only.
// 1. Create a WebSocketFactory instance.
WebSocketFactory factory = new WebSocketFactory();
// 2. Set up information about a proxy server.
// Credentials can be set here.
ProxySettings settings = factory.getProxySettings();
settings.setServer("http://proxy.example.com");
settings.setCredentials("id", "password");
// 3. Connect to a WebSocket endpoint via the proxy.
WebSocket ws = factory.createSocket("ws://websocket.example.com");
// 4. Add a listener to receive WebSocket events.
ws.addListener(new WebSocketAdapter() {
#Override
public void onTextMessage(WebSocket ws, String message) {
// Received a text message.
......
}
});
// 5. Perform a WebSocket opening handshake.
ws.connect();
// 6. Send frames.
// 6-1. Text
ws.sendText("Hello.");
// 6-2. Binary
byte[] binary = ......;
ws.sendBinary(binary);
// 6-3. Ping
ws.sendPing("Are you there?");
// 6-4. Pong (unsolicited pong; RFC 6455, 5.5.3. Pong)
ws.sendPong("I'm OK.");
// 6-5. Fragmented Frames
ws.sendText("How ", false)
.sendContinuation("are ")
.sendContinuation("you?", true);
// 6-6. Periodical Ping
ws.setPingInterval(60 * 1000);
// 6-7. Periodical Pong (unsolicited pong; RFC 6455, 5.5.3. Pong)
ws.setPongInterval(60 * 1000);
// 6-8. Close (if you want to send one manually).
ws.sendClose(WebSocketCloseCode.NORMAL, "Bye.");
// 7. Disconnect
ws.disconnect();
Blog
WebSocket client library (Java SE 1.5+, Android)
http://darutk-oboegaki.blogspot.jp/2015/05/websocket-client-library-java-se-15.html
GitHub
https://github.com/TakahikoKawasaki/nv-websocket-client
JavaDoc
http://takahikokawasaki.github.io/nv-websocket-client/
Maven
<dependency>
<groupId>com.neovisionaries</groupId>
<artifactId>nv-websocket-client</artifactId>
<version>1.3</version>
</dependency>
The size of nv-websocket-client-1.3.jar is 62,854 bytes and it does not require any external dependencies.
You can try Tyrus (reference implementation of WebSocket API in Java EE); client side does not require any Java EE server to be running and if you are using Java 7, the client could be minimized to ~500kb.
Client behing proxy and Dependencies should provide enough info to try.

how to trigger a gcm to send a push notification to android device(using java server)

I am very new to java server side development, i have followed this link [http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/][1] and successfully implemented GCM with my android device, the problem is dont know how to trigger the GCM server while the content is updated in my db,i need to notify each and every update of my db to the user, am i need to watch the db using timer task something like that or is there any default solution to keep track of db ?
My Server side code :
regId = "my registration id";
String userMessage = request.getParameter("message");
Sender sender = new Sender(GOOGLE_SERVER_KEY);
Message message = new Message.Builder().timeToLive(30)
.delayWhileIdle(true).addData(MESSAGE_KEY, userMessage).build();
result = sender.send(message, regId, 1);
have tried with many solution but till now not getting exact solution, Suggestion, ideas or related links are most welcome
Thanks in advance
Without knowing the specific functionality of your server and app, I can only offer a general solution.
Each process in your server that performs DB updates that have to be pushed to some Android devices via GCM can write the messages and the registration IDs to some kind of queue.
Then you can have another process (or processes) that would consume the queue of GCM messages, and send them to Google. These processes can handle failures (retry sending the messages in case of temporary failures), and update your database of registration IDs if they receive responses with canonical registration IDs or errors such as InvalidRegistration or NotRegistered.

How to assign a sender name in SMSLib?

I'm using SMSLib in my java application to send messages, I make that using a usb modem as a gateway and send the messages to any phone throw it, the point here that when i receive the message it displays the sender as the sim number(the sim that exists in the usb modem).
The thing i want to do is to assign a name instead of the sim number so the recipient will see that name not the usb modem sim number
In most cases sender name is overridden by the Service Provider to their identification 'SIM number'.
By the Library it provides two locations to set sender information.
On gateway level
SerialModemGateway gateway = new SerialModemGateway("modem.com4",
"COM4", 57600, "Huawei", "E160");
gateway.setFrom("chandpriyankara");
On Message level
SMS
OutboundMessage msg = new OutboundMessage("+94123456789",
"SMS test: sample message from StackOverflow");
msg.setFrom("chandpriyankara");
I couldn't set a customer sender for SMS from either of my tested SMS providers[GSM Providers]. But this should work for buld SMS gateways. You have to discuss this with your service provider.
WAP
OutboundWapSIMessage wapMsg = new OutboundWapSIMessage("+94123456789",
new URL("http://stackoverflow.com/"),
"WAP test: sample message from StackOverflow!");
wapMsg.setFrom("chandpriyankara");
For WAP messages, some of GSM providers set my custom sender details, but not all.
You can put sender information to your message instance before sending.
message.setFrom("your sender information");
Additionally it may depend on your GSM provider.

How do I manually beam an NdefMessage with Android?

I have my NFC class which I assume people know what it looks like if you are looking at this question. So OnCreate, I do:
mNfcAdapter.setNdefPushMessageCallback(this, this);
to be able to send messages and then I do:
public NdefMessage createNdefMessage(NfcEvent event){
NdefMessage msg;
msg = new NdefMessage(new NdefRecord[] {
createApplicationRecord(this.messageToSend.getBytes())
});
return msg;
}
to send my message. and I have some code to receive a message as well but then I want to send another message back while the devices are still in "Connected" mode. How can I manually give a "send message" command?
Your application gets a single chance to send out the message using setNdefPushMessageCallback. Once the message has been transfered you get the completionCallback (if you want to). Afterwards you can't interact with NFC anymore.
Sending a second message after you got your completion is unfortunately not possible with the API as it is right no.
Technically there is no reason for this by the way. Google could add the functionality with ease. It would only take them a day or two. In Android 2.3 there already was an undocumented way to access the LLCP (base protocol of Android Beam) protocol from applications. This is gone since Android 3.0

Categories

Resources