Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Gear Lib | 2,631 | a month ago | 10 | mit | C | |||||
Gear-Lib, C library for IOT Embedded Multimedia and Network | ||||||||||
Android Priority Jobqueue | 2,443 | 86 | 7 | 7 years ago | 7 | February 19, 2014 | 33 | Java | ||
A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability. | ||||||||||
X | 1,608 | 14 hours ago | 4 | mit | C# | |||||
Core basic components: log (file / network), configuration (XML / JSON / HTTP), cache (memory / redis), network (TCP / UDP / HTTP), RPC framework, serialization (binary / XML / JSON), APM performance tracking. 核心基础组件,日志(文件/网络)、配置(XML/Json/Http)、缓存(内存/Redis)、网络(Tcp/Udp/Http)、RPC框架、序列化(Binary/XML/Json)、APM性能追踪。 | ||||||||||
Brynet | 904 | a month ago | 26 | mit | C++ | |||||
A Header-Only cross-platform C++ TCP network library . We can use vcpkg(https://github.com/Microsoft/vcpkg/tree/master/ports/brynet) install brynet. | ||||||||||
Invoke Socksproxy | 574 | 2 years ago | mit | PowerShell | ||||||
Socks proxy, and reverse socks server using powershell. | ||||||||||
Pink | 294 | 2 years ago | 6 | bsd-3-clause | C++ | |||||
A high performance network library | ||||||||||
Ot Br Posix | 291 | 10 hours ago | 64 | bsd-3-clause | C++ | |||||
OpenThread Border Router, a Thread border router for POSIX-based platforms. | ||||||||||
Chronicle Network | 234 | 5 | 1 | a month ago | 296 | December 08, 2022 | 2 | apache-2.0 | Java | |
A High Performance Network ( TCP/IP ) Library | ||||||||||
Znet | 141 | a year ago | 2 | mit | C | |||||
A C network library | ||||||||||
Insightscan | 132 | 7 years ago | 2 | unlicense | Python | |||||
A single file multithread portscanner in python |
Introducing Volley Ball for Android, an extension library built on top of Volley. For those who didn't hear about Volley, it's a networking library used by Google engineers in their Android apps and presented to public during the Google IO 2013. You can find more about Volley in the Google IO talk: http://www.youtube.com/watch?v=yhv8l9F44qo.
Perform the request in your activity / fragment :
mRequestQue.add(new SampleRequest(Request.Method.GET, "http://some.url", new ResponseListener<Object>() {
@Override
public void onIntermediateResponse(Object response, BallResponse.ResponseSource responseSource) {
// intermediate response, such as from local database or soft cached network response
}
@Override
public void onFinalResponse(Object response, BallResponse.ResponseSource responseSource) {
// final response, which is the network response
}
@Override
public void onFinalResponseIdenticalToIntermediate(BallResponse.ResponseSource responseSource) {
// final response is identical to intermediate one
// happens when intermediate is from soft cache and network response is identical (not modified)
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// network response is an error, in the same way than with volley
}
}
));
And the request class looks like :
public class SampleRequest extends CompleteRequest<Object> {
public SampleRequest(int method, String url, ResponseListener<Object> responseListener, Response.ErrorListener errorListener) {
super(method, url, responseListener, errorListener);
}
@Override
protected Object getLocalResponse() {
// query your local database for example
// return the result or null if there is no result from database
return new Object();
}
@Override
public void saveNetworkResponseToLocal(Object response) {
// save the network response to the local database
// next time the request is performed the local response will return the result faster than the network request
}
@Override
protected BallResponse<Object> parseBallNetworkResponse(NetworkResponse response) {
// parse the result from the network request, in the same way than with volley
return Response.success(new Object());
}
}
You can still use Volleball the same way you would use Volley, with a network-only request and exact same features (cache and stuff). You need to extend NetowkrRequest for that :
public class MyNetworkRequest extends NetworkRequest<String> {
public MyNetworkRequest(SingleResponseListener<String> listener, ErrorListener errorListener) {
super(Method.GET, "some.url.com", listener, errorListener);
}
@Override
protected BallResponse<String> parseBallNetworkResponse(NetworkResponse response) {
return BallResponse.success("some response that you would parse from response.data", HttpHeaderParser.parseCacheHeaders(response));
}
}
You can even use Volleyball to perform non-networking task outside of UI thread, using the powerful thread dispatching of Volley. You need to extend LocalRequest for that. As you can see, the main difference is that the local request does not have a HTTP method, a url or an error listener. It's up to you to catch any exception and return an adequate result. One of the purpose of this kind of request is to query your local database outside of UI thread, which is always a good practice.
public class SampleLocalRequest extends LocalRequest<String> {
public SampleLocalRequest(ResponseListener<String> responseListener) {
super(responseListener);
}
@Override
public String performLocal() {
// outside of UI thread
return "something if you want";
}
}
For either network-only or local-only request, you run the request in the following way, with a simplified response listener:
// network request
NetworkRequest request = new SampleNetworkRequest(Request.Method.GET, "some.url.com", new SingleResponseListener<String>() {
@Override
public void onResponse(String response) {
SimpleLogger.d("response from request %s", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
SimpleLogger.d("error from request %s", error.getMessage());
}
});
Application.getRequestQueue().add(request);
// local request that returns something
LocalRequest localRequest = new SampleLocalRequest(new SingleResponseListener<String>() {
@Override
public void onResponse(String response) {
SimpleLogger.d("response from request %s", response);
}
});
mRequestQueue.add(localRequest);
// local request that returns nothing
LocalRequest localRequestWithoutResult = new SampleLocalNoResultRequest();
mRequestQueue.add(localRequestWithoutResult);
You can checkout the samples project for the full code source, and specifically the following three activities:
The Android API and its ecosystem offer a lot of great libraries for working with background threads and networking task: AsyncTasks, Loaders, Robospice, Retrofit and so on. Volley is great for performing network tasks very easily. However, none of these libraries offer a full support for a very common use case we developers encounter while making Android apps and working with some web service (REST or not): Display some data from www.foobar.com/api/data (in whatever format we want).
The very first request of the app will look like:
Volley works great with this process. But the next requests will look more like:
Volley do offer a local cache of requests out of the box, but:
In summary, even if there are some workarounds to fix these drawbacks, it's often more convinient to have our data stored in a local database. Here comes the main use case of Volley Ball, it provides a local request processing along with the network one.
PICS
In Volley Ball, a request is composed of two kind of "sub" request:
Volley Ball introduces concurrency with parallel worker threads, something the original Volley library does not have (basically, it's a sequential process of: request -> cache -> maybe response -> network -> response). With Volley Ball we have the local worker thread and the cache/network one running in parallel, which result in a more complicated logic.
Let's see the possible scenarios when running a volley ball request and its implications. These scenarios are tested in working conditions in the sample project.
NB1: Each time we start a request, the request queue dispatches it to the two following worker thread that will run in parallel:
NB2: Only the first intermediate and valid response is taken in account, either from local or from cache.
Scenario 1
Scenario 2
Scenario 3
Scenario 4 (points 2 and 3 can be inverted)
Scenario 5 (points 2 and 3 can be inverted)
Scenario 6 (points 2 and 3 can be inverted)
Scenario 7
Scenario 8 (points 2 and 3 can be inverted)
Scenario 9
Scenario 10
Enable detailled request logs in the same way than with Volley : adb shell setprop log.tag.Volley VERBOSE
Volley Ball is built on top of Volley, which is included as a git submodule from https://android.googlesource.com/platform/frameworks/volley. Sadly, Volley uses several times the private and default scopes which obligated me to copy past some pieces of code. It's documented in the source code. Current version of the Volley sub module: 4c2fe13.
You can run the tests with the command line: ./gradlew library:unitTest
Volleyball relies on Volley library as jar dependency.
You can deploy one using this clone of the Google Volley repository: lukaspili/Android-Volley-gradle-library
Then run: mvn clean install
to deploy the volley jar in your local or remote repository.
check the request cancelation
local request only
several worker threads for local dispatcher
compatibility for adding volley request to the ball queue
marker log finished
cancel, finish from several parallel work threads
test coverage (0% so far)
scenario 7-8 soft cache request has been delivered shouldn't be volatile ?
request finished volatile -> finished only from executor
cancellation
local and network only request
marker log constant methods
local request final ?
add shouldCache NO for local request
add shouldCache / softcache for other requests