Using WebSocket with OkHttp
● Repos
https://github.com/square/okhttp/tree/master/okhttp-ws
Note: This module's API should be considered experimental
and may be subject to breaking changes in future releases.
Slide 7
Slide 7 text
Using WebSocket with OkHttp
● add dependencies
※ need permission: android.permission.INTERNET
● create WebSocketListener extends class
…show my sample code.
compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
Slide 8
Slide 8 text
Sample code
● Okhttp-ws: repo
Only 7 classes :-)
sample class: WebSocketEcho.java
WebSocet test: https://www.websocket.org/echo.html
● My sample
https://github.com/kaelaela/WebSockcetSample
Slide 9
Slide 9 text
History of okhttp-ws
● Version 2.3.0: Beta release
● Version 2.4.0-RC1: Bug fix
● Version 2.4.0: WebSocketListener has incompatible changes.
● Version 2.6.0:
○ WebSocket API now uses RequestBody and
ResponseBody for messages.
○ Bug fix
● Version 3.1.0: WebSockets now defer some writes.
● Version 3.3.1: Bug fix
Slide 10
Slide 10 text
Milestone of okhttp-ws
v3.5(Due by August 31, 2016)
● some bug fix
v3.6(Due by September 30, 2016)
● some bug fix
● status code enhancement(issue)
But, most issues are deferred. Let pray.
more information: show websocket label
Slide 11
Slide 11 text
Retrofit?
maybe add v2.2!!!(No due date. 29% complete at 2016-08-21.)
● Issue #924
● Commit
interface Service {
@GET("/chat/{id}")
Call chat(@Path("id") String id);
}