I have a Node.js app that uses HTTP / REST (using Express.js), and a native Android application that communicates with this. This works fine.
I am now looking at writing a more real-time version, which can push messages to a native client. Unfortunately, it needs to be a native client, as there is some fairly complex work done with the data that simply will not be possible in a mobile browser for the forseable future (otherwise I would just wait for WebSockets support to appear in the Android browser).
So, my question is what are my options?
I know about the Android Cloud to Device Messaging framework, but this requires registration and a Google sign-in, and I would much prefer the server to be client agnostic.
Is there a reliable WebSocket client that I can use (ideally) to talk to a Node.js server running Socket.io? Or any other native method (using the NIO classes)?
The WebSocket protocol paved the way to a truly realtime web. At the time of writing this article, the Android SDK does not have native support for WebSockets. However, it relies on the Java Development Kit (JDK), which includes support for WebSockets as part of javax. websocket package.
Definitely, a WebSocket web app will run on any HTML5-compliant browser, including mobile browsers such as Safari for iOS and Chrome for mobile.
React Native also supports WebSockets, a protocol which provides full-duplex communication channels over a single TCP connection.
See Java socket.io client
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With