Slide 1

Slide 1 text

WebSocket  For Android @kaelaela(Yuichi Maekawa) Twitter: kaelaela31 Github: kaelaela

Slide 2

Slide 2 text

Overview of WebSocket ● Bidirectional communication ● port: 80 or 443 ● scheme: ws or wss ● binary support ● RFC6455

Slide 3

Slide 3 text

Pros ● No request header(So, hi-Speed!) ● Real time communication ● available HTTP resource(proxy, filter, auth...)

Slide 4

Slide 4 text

Cons ● Difficult error handling ● Difficult re-connection handling ● Do not control message priority

Slide 5

Slide 5 text

Popular WebSocket libraries ● Socket.io ● Java-websocket ● Okhttp-ws ● java.net.Socket

Slide 6

Slide 6 text

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); }

Slide 12

Slide 12 text

Thx ;-) Http2? I don’t know.