socketio / engine.io-client-java

Engine.IO Client Library for Java
http://socketio.github.io/engine.io-client-java
Other
359 stars 167 forks source link

Options for inject okhttp Call/WebSocket factory #85

Closed b95505017 closed 7 years ago

b95505017 commented 7 years ago

http://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html

OkHttpClients should be shared

81

Now the library could inject the implementation of Call.Factory/WebSocket.Factory, usually they are the singleton of OkHttpClient instance. You could have your own factory implementation, which means that doesn't have to be OkHttpClient! Such as a mock implementation. Attributes in Options such as hostnameVerifier, proxy, SSLContext, proxyLogin proxyPassword please set directly into OkHttpClient, and there are more attributes you could setup in OkHttpClient, please take a look.

nkzawa commented 7 years ago

It looks this PR made running tests about 4x slower. Do you know why ?

b95505017 commented 7 years ago

https://github.com/socketio/engine.io-client-java/pull/85/files#diff-e59436b8700f3e846c198934e8de44cdR20 Because OkHttp will not shutdown right after test execution done.

The threads and connections that are held will be released automatically if they remain idle. http://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html

I just increase the timeout waiting time currently.

nkzawa commented 7 years ago

@b95505017 👍 Makes sense. We can improve it later.

nkzawa commented 7 years ago

I just realized these options make the library really flexible. It's amazing 😄