Slide 1

Slide 1 text

WebSocket For Android ver.2 @kaelaela(Yuichi Maekawa) 鳥: kaelaela31 蛸猫: kaelaela

Slide 2

Slide 2 text

ver.1 https://speakerdeck.com/kaelaela/websocket-for-android on Aug 23, 2016 @ Wantedly

Slide 3

Slide 3 text

The next day

Slide 4

Slide 4 text

> BROADCAST DESTROY < #REF! -> Broadcast Destroy: http://konifar-zatsu.hatenadiary.jp/entry/2016/07/27/020130

Slide 5

Slide 5 text

But

Slide 6

Slide 6 text

This entry’s target is enterprise services.

Slide 7

Slide 7 text

Sounds logical. I agree to you only if enterprise services.

Slide 8

Slide 8 text

For normal mobile app ● Almost all services have no proxy ● Need real time update!(messaging app or game) ● Need low energy consumption! > If you make long polling system, the user say  “Battery fire!” and put 1 star...

Slide 9

Slide 9 text

Use WebSocket in peace ;-)

Slide 10

Slide 10 text

Do you know okhttp-ws?

Slide 11

Slide 11 text

Sample code ● My sample Android project https://github.com/kaelaela/WebSockcetSample

Slide 12

Slide 12 text

okhttp-ws

Slide 13

Slide 13 text

Update of okhttp-ws ● Add to main repos on v3.5.0!!(SNAPSHOT now)  PR: #2852    https://github.com/square/okhttp/pull/2852 compile 'com.squareup.okhttp3:okhttp-ws:3.4.1' compile 'com.squareup.okhttp3:okhttp:3.5.0'

Slide 14

Slide 14 text

Update of okhttp-ws ● Remove ws package ● Add method to OkHttpClient okhttp3.ws.* -> okhttp3.* newWebSocketCall

Slide 15

Slide 15 text

Sample code diff ● 3.4.1 -> 3.5.0 https://github.com/kaelaela/WebSockcetSample/commit/45b88ad2ecc5a89dbd493 fc3cc25152511e28529

Slide 16

Slide 16 text

Echo test: websocket.org

Slide 17

Slide 17 text

Echo test: websocket.org Supports TLS.

Slide 18

Slide 18 text

Retrofit? -> No change. It will be added in v2.2!!! (No due date. 31% complete at 2016-09-16.) ● Issue #924 ● Commit interface Service { @GET("/chat/{id}") Call chat(@Path("id") String id); }

Slide 19

Slide 19 text

Let’s replace your http client with okhttp! If your project use okhttp.

Slide 20

Slide 20 text

Thx ;-)