Connect with iOS and Android clients to SockJS Backend

北慕城南 提交于 2019-12-02 20:06:49

Maybe it's more than a year since the question was asked. But, because it's getting in the first results when Googling for SockJS+Android. So, I am posting my answer.

From my experience with a recent project I worked on, we were able to use a STOMP client - like the one here- to connect to Spring Websocket backend from native Android app.

And from the browser, you can still use SockJS client to gain across browsers compatibility to websockets with fallback.

A note to mention that when using only STOMP client to connect to native websocket the URL will be something like ws://mydomain/SockJSEndpoint/websocket, and when using SockJS client from the browser the URL will be like http://mydomain/SockJSEndpoint.

SockJS may be interesting because it provides non-ws transports. Just using WebSockets may not be possible in all situations.

There is one cross-platform SockJs client of the OpenFL project:

https://github.com/jeremyfa/openfl-sockjs

Not tested how well it works, but at least for Android it's using JavaScript from inside WebView, so should be no different than JavaScript one. Again, it is not clear how tightly it is coupled with OpenFL, but the approach of using WebView and stock SockJS client could probably be re-used.

We have tested them, both Android-client (link) was given by @Amr K. Ismail and

this iOS-client (link) are suitable with Spring-SockJS-Server which has STOMP.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!