Can I connect to WebSocket in an Android app?

I have an Android app and I want to send text from an Android app to a web page using HTML5 WebSocket .

Is this possible, and if so, how?

+4
source share
4 answers

A simple google search for 'android websockets' appeared this . He means the GitHub project called websocket-android-phonegap .

+4
source

I know 2 libs for Android that support WebSockets from native applications

http://code.google.com/p/weberknecht

https://github.com/tavendo/AutobahnAndroid

Autobahn supports RFC6455 (the final WS specification), integrates well with user interfaces and service applications, and supports RPC and PubSub via WebSockets.

Disclaimer: I am the author of Autobahn.

+13
source

Another alternative that may be considered is the Eneter Messaging Framework.
It is a cross-platform platform for interprocess communication, which is also available for Android and supports web ports. Technical summary can be found here:
http://www.eneter.net/ProductInfo.htm

Websocket Online Help Support for Java and Android:
http://www.eneter.net/OnlineHelp/EneterMessagingFrameworkJava/eneter/messaging/messagingsystems/websocketmessagingsystem/package-summary.html

0
source

Answer: Yes, you can send text from the application to the web page. WebSocket works by the very principle of server and client through TCP / IP. Just a shell created at the TCP / IP level and built a new data format that is defined by the IETF. Detailed information on the data format is available at: [ https://tools.ietf.org/html/rfc6455:51[1]

The server accepts a web socket connection if requested in the correct format. A client is a web application in which javascript objects are defined exclusively for this purpose in HTML5.

Easy to use APIs:

Programming client-side websites is very easy using new APIs and objects.

API (events) available to the developer: onopen, onclose, onmessage. All these functions must be defined by the java script developers.

onopen: the function is called when the server successfully accepts connections

onclose: function called when socket connection is closed

onmessage: the function is called when data is received from the server.

send: the function is not event-based, but should be started when the client has information to exchange with the server.

0
source

All Articles