-
Notifications
You must be signed in to change notification settings - Fork 47
Sending and Receiving Binary Data
fstn edited this page Sep 27, 2017
·
6 revisions
To send and receive binary data using wAsync, you need to set the RequestBuilder's content-type to
request = client.newRequestBuilder()
.method(Request.METHOD.GET)
**.header("Content-Type", "application/octet-stream")**
You must add this header, because Atmosphere ignore content-type
X-Atmosphere-Binary: true
Starting with 1.3.0, you can also set the OptionsBuilder.binary(true)
in order to turn on binary support
socket = client.create(client.newOptionsBuilder().binary(true).build());
Then you can define a Decoder that accept bytes
socket.on("message", new Function<byte[]>() {
@Override
public void on(byte[] message) {
...
}
})