Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Androidasync | 7,308 | 285 | 22 | 6 months ago | 65 | November 08, 2020 | 351 | other | Java | |
Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads. | ||||||||||
Mobileimsdk | 4,799 | 9 days ago | 13 | apache-2.0 | Objective-C | |||||
一个原创多端IM通信层框架,轻量级、高度提炼,历经8年、久经考验。可能是市面上唯一同时支持UDP+TCP+WebSocket三种协议的同类开源框架,支持 iOS、Android、Java、H5、小程序、Uniapp,服务端基于Netty。 | ||||||||||
Happychat | 389 | 6 years ago | 6 | apache-2.0 | Java | |||||
基于Netty实现的WebSocket聊天室,支持几万人同时在线聊天 | ||||||||||
Firenio | 320 | 1 | 2 years ago | 14 | November 01, 2020 | 9 | apache-2.0 | Java | ||
🐳🐳An easy of use io framework project based on java nio&epoll | ||||||||||
Voovan | 263 | a day ago | 1 | apache-2.0 | Java | |||||
Voovan是高性能异步通信、HTTP服务器和客户端通信、动态编译支持、数据库操作帮助类等工具的框架, 如果项目觉得不错, 请点一下 star, 谢谢 | ||||||||||
Grizzly | 209 | 2 years ago | 1 | other | Java | |||||
Writing scalable server applications in the Java™ programming language has always been difficult. Before the advent of the Java New I/O API (NIO), thread management issues made it impossible for a server to scale to thousands of users. The Grizzly NIO framework has been designed to help developers to take advantage of the Java™ NIO API. | ||||||||||
Springboot Cli | 111 | a year ago | 1 | mit | Java | |||||
Springboot、SpringCloud各种常用框架使用案例,完善的文档,致力于让开发者快速搭建基础环境并让应用跑起来,并提供丰富的使用示例供使用者参考,快速上手。 | ||||||||||
Magician | 100 | 7 months ago | mit | Java | ||||||
Magician is a small HTTP service package based on Netty that makes it very easy to start an http service, and also supports WebSocket, using annotated configuration Handler, If you want to develop an http service with netty but find it cumbersome, then Magician may help you. | ||||||||||
Uzhttp | 96 | 1 | a year ago | 15 | December 18, 2021 | 4 | apache-2.0 | Scala | ||
Minimal HTTP server for Scala+ZIO | ||||||||||
Cshbbrain | 68 | 5 years ago | 4 | Java | ||||||
CshBBrain |
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(s) client/server, and WebSocket library for Android, AndroidAsync is it.
Download the latest JAR or grab via Maven:
<dependency>
<groupId>com.koushikdutta.async</groupId>
<artifactId>androidasync</artifactId>
<version>(insert latest version)</version>
</dependency>
Gradle:
dependencies {
compile 'com.koushikdutta.async:androidasync:2.+'
}
// url is the URL to download.
AsyncHttpClient.getDefaultInstance().getString(url, new AsyncHttpClient.StringCallback() {
// Callback is invoked with any exceptions/errors, and the result, if available.
@Override
public void onCompleted(Exception e, AsyncHttpResponse response, String result) {
if (e != null) {
e.printStackTrace();
return;
}
System.out.println("I got a string: " + result);
}
});
// url is the URL to download.
AsyncHttpClient.getDefaultInstance().getJSONObject(url, new AsyncHttpClient.JSONObjectCallback() {
// Callback is invoked with any exceptions/errors, and the result, if available.
@Override
public void onCompleted(Exception e, AsyncHttpResponse response, JSONObject result) {
if (e != null) {
e.printStackTrace();
return;
}
System.out.println("I got a JSONObject: " + result);
}
});
Or for JSONArrays...
// url is the URL to download.
AsyncHttpClient.getDefaultInstance().getJSONArray(url, new AsyncHttpClient.JSONArrayCallback() {
// Callback is invoked with any exceptions/errors, and the result, if available.
@Override
public void onCompleted(Exception e, AsyncHttpResponse response, JSONArray result) {
if (e != null) {
e.printStackTrace();
return;
}
System.out.println("I got a JSONArray: " + result);
}
});
AsyncHttpClient.getDefaultInstance().getFile(url, filename, new AsyncHttpClient.FileCallback() {
@Override
public void onCompleted(Exception e, AsyncHttpResponse response, File result) {
if (e != null) {
e.printStackTrace();
return;
}
System.out.println("my file is available at: " + result.getAbsolutePath());
}
});
// arguments are the http client, the directory to store cache files,
// and the size of the cache in bytes
ResponseCacheMiddleware.addCache(AsyncHttpClient.getDefaultInstance(),
getFileStreamPath("asynccache"),
1024 * 1024 * 10);
AsyncHttpPost post = new AsyncHttpPost("http://myservercom/postform.html");
MultipartFormDataBody body = new MultipartFormDataBody();
body.addFilePart("my-file", new File("/path/to/file.txt");
body.addStringPart("foo", "bar");
post.setBody(body);
AsyncHttpClient.getDefaultInstance().executeString(post, new AsyncHttpClient.StringCallback(){
@Override
public void onCompleted(Exception ex, AsyncHttpResponse source, String result) {
if (ex != null) {
ex.printStackTrace();
return;
}
System.out.println("Server says: " + result);
}
});
AsyncHttpClient.getDefaultInstance().websocket(get, "my-protocol", new WebSocketConnectCallback() {
@Override
public void onCompleted(Exception ex, WebSocket webSocket) {
if (ex != null) {
ex.printStackTrace();
return;
}
webSocket.send("a string");
webSocket.send(new byte[10]);
webSocket.setStringCallback(new StringCallback() {
public void onStringAvailable(String s) {
System.out.println("I got a string: " + s);
}
});
webSocket.setDataCallback(new DataCallback() {
public void onDataAvailable(DataEmitter emitter, ByteBufferList byteBufferList) {
System.out.println("I got some bytes!");
// note that this data has been read
byteBufferList.recycle();
}
});
}
});
AsyncHttpServer server = new AsyncHttpServer();
List<WebSocket> _sockets = new ArrayList<WebSocket>();
server.get("/", new HttpServerRequestCallback() {
@Override
public void onRequest(AsyncHttpServerRequest request, AsyncHttpServerResponse response) {
response.send("Hello!!!");
}
});
// listen on port 5000
server.listen(5000);
// browsing http://localhost:5000 will return Hello!!!
AsyncHttpServer httpServer = new AsyncHttpServer();
httpServer.listen(AsyncServer.getDefault(), port);
httpServer.websocket("/live", new AsyncHttpServer.WebSocketRequestCallback() {
@Override
public void onConnected(final WebSocket webSocket, AsyncHttpServerRequest request) {
_sockets.add(webSocket);
//Use this to clean up any references to your websocket
webSocket.setClosedCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
try {
if (ex != null)
Log.e("WebSocket", "An error occurred", ex);
} finally {
_sockets.remove(webSocket);
}
}
});
webSocket.setStringCallback(new StringCallback() {
@Override
public void onStringAvailable(String s) {
if ("Hello Server".equals(s))
webSocket.send("Welcome Client!");
}
});
}
});
//..Sometime later, broadcast!
for (WebSocket socket : _sockets)
socket.send("Fireball!");
All the API calls return Futures.
Future<String> string = client.getString("http://foo.com/hello.txt");
// this will block, and may also throw if there was an error!
String value = string.get();
Futures can also have callbacks...
Future<String> string = client.getString("http://foo.com/hello.txt");
string.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
System.out.println(result);
}
});
For brevity...
client.getString("http://foo.com/hello.txt")
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
System.out.println(result);
}
});