在Android應用中使用哪個WebSocket套件?

我Google 了一下,找到很多個套件可以使用。

/AndroidAsync

目前這套件在 2017-10-27 的星星數目: 4673


/nv-websocket-client

目前這套件在 2017-10-27 的星星數目: 698


/Java-WebSocket

目前這套件在 2017-10-27 的星星數目: 3317


上面 3個,照星星數來排,應該用 4000星的,我試了一下,範例沒辦法快速地套用上去,所以改用 3000星星的,3000星星的有附範例,是很快就可以用了,但問題是遇到自簽的SSL憑證就卡關了,雖然官方有附SSL範例,但弄了好幾個小時還是卡住,改用 700星星的,立馬就解決,也可以輕鬆地連到self-signed wss 伺服器,結論,星星多不一定比較好用,或著可能是功力太弱,無法快速地參悟別人設計上的用法。

 

現在似乎有一堆Java WebSocket庫,我不知道應該使用哪一個:


TooTallNate/Java-WebSocket

GitHub的描述:

This repository contains a barebones WebSocket server and client implementation written in 100% Java. The underlying classes are implemented java.nio, which allows for a non-blocking event-driven model (similar to theWebSocket API for web browsers).

Implemented WebSocket protocol versions are:

Here some more details about protocol versions/drafts.


koush/AndroidAsync

GitHub的描述:

AndroidAsync is a low level network protocol library. If you are looking for an easy to use, higher level, Android aware, http request library, check out Ion (it is built on top of AndroidAsync). The typical Android app developer would probably be more interested in Ion.

But if you’re looking for a raw Socket, HTTP client/server, WebSocket, and Socket.IO library for Android, AndroidAsync is it.

Features

  • Based on NIO. One thread, driven by callbacks. Highly efficient.

  • All operations return a Future that can be cancelled

  • Socket client + socket server

  • HTTP client + server

  • WebSocket client + server

  • Socket.IO client


Jetty WebSocket Client API
https://www.eclipse.org/jetty/documentation/9.3.x/index.html

Jetty還提供了一個Jetty WebSocket客戶端庫來編寫與WebSocket服務器交談更容易。


Atmosphere/wasync

GitHub的描述:

wAsync is a Java based library allowing asynchronous communication with any WebServer supporting the WebSocket or Http Protocol. wAsync can be used with Node.js, Android, Atmosphere or any WebSocket Framework. To get started, read this super simple Tutorial or read the FAQ

You can browse the javadoc or browse our samples.


 TakahikoKawasaki/nv-websocket-client

GitHub的描述:

High-quality WebSocket client implementation in Java which

  • complies with RFC 6455 (The WebSocket Protocol),

  • works on Java SE 1.5+ and Android,

  • supports all the frame types (continuation, binary, text, close, ping and pong),

  • provides a method to send a fragmented frame in addition to methods for unfragmented frames,

  • provides a method to get the underlying raw socket of a WebSocket to configure it,

  • provides a method for Basic Authentication,

  • provides a factory class which utilizes javax.net.SocketFactory interface,

  • provides a rich listener interface to hook WebSocket events,

  • has fine-grained error codes for fine-grained controllability on errors,

  • allows to disable validity checks on RSV1/RSV2/RSV3 bits and opcode of frames,

  • supports HTTP proxy, especially “Secure WebSocket” (wss) through “Secure Proxy” (https),

  • and supports RFC 7692 (Compression Extensions for WebSocket), also known as permessage-deflate (not enabled by default).


square/okhttp

GitHub的描述:

An HTTP & HTTP/2 client for Android and Java applications. For more information see the website and the wiki.


firebase/TubeSock

GitHub的描述:

TubeSock is a Java implementation of the client side of the WebSocket Protocol for use in Java applications.


Autobahn|Android(GitHub)

GitHub的描述:

Client library providing WAMP on Java 8 (Netty) and Android, plus (secure) WebSocket for Android.

Docker Hub | Travis Docs


Autobahn|Java is a subproject of the Autobahn project and provides open-source client implementations for

running on Android and Netty/Java8/JVM.

The WebSocket layer is using a callback based user API, and is specifically written for Android. Eg it does not run any network stuff on the main (UI) thread.

The WAMP layer is using Java 8 CompletableFuture for WAMP actions (call, register, publish and subscribe) and the Observer pattern for WAMP session, subscription and registration lifecycle events.

The library is MIT licensed, maintained by the Crossbar.io Project, tested using the AutobahnTestsuite and published as a JAR to Maven and as a Docker toolchain image to Dockerhub.


nkzawa/socket.io-client.java

GitHub的描述:

This is the Socket.IO v1.x Client Library for Java, which is simply ported from the JavaScript client.

See also:

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *