xref: /aosp_15_r20/external/okhttp/okhttp-ws/README.md (revision ab625e417e7950f52094c019474d2a9e9f14a68c)
1*ab625e41SAndroid Build Coastguard WorkerOkHttp Web Sockets
2*ab625e41SAndroid Build Coastguard Worker==================
3*ab625e41SAndroid Build Coastguard Worker
4*ab625e41SAndroid Build Coastguard WorkerRFC6455-compliant web socket implementation.
5*ab625e41SAndroid Build Coastguard Worker
6*ab625e41SAndroid Build Coastguard WorkerCreate a `WebSocketCall` with a `Request` and an `OkHttpClient` instance.
7*ab625e41SAndroid Build Coastguard Worker```java
8*ab625e41SAndroid Build Coastguard WorkerWebSocketCall call = WebSocketCall.create(client, request);
9*ab625e41SAndroid Build Coastguard Worker```
10*ab625e41SAndroid Build Coastguard Worker
11*ab625e41SAndroid Build Coastguard WorkerA `WebSocketListener` will notify of the initial connection, server-sent messages, and any failures
12*ab625e41SAndroid Build Coastguard Workeron the connection.
13*ab625e41SAndroid Build Coastguard Worker
14*ab625e41SAndroid Build Coastguard WorkerStart the web socket by calling `enqueue` on `WebSocketCall` with the `WebSocketListener`.
15*ab625e41SAndroid Build Coastguard Worker```java
16*ab625e41SAndroid Build Coastguard Workercall.enqueue(new WebSocketListener() {
17*ab625e41SAndroid Build Coastguard Worker  // ...
18*ab625e41SAndroid Build Coastguard Worker});
19*ab625e41SAndroid Build Coastguard Worker```
20*ab625e41SAndroid Build Coastguard Worker
21*ab625e41SAndroid Build Coastguard Worker*Note: This module's API should be considered experimental and may be subject to breaking changes
22*ab625e41SAndroid Build Coastguard Workerin future releases.*
23