public final class WebSocketWriter extends Object
This class is partially thread safe. Only a single "main" thread should be sending messages via
calls to newMessageSink(int)
, writePing(okio.Buffer)
, or writeClose(int, java.lang.String)
. Other threads may
call writePing(okio.Buffer)
, writePong(okio.Buffer)
, or writeClose(int, java.lang.String)
which will interleave on the
wire with frames from the "main" sending thread.
Constructor and Description |
---|
WebSocketWriter(boolean isClient,
okio.BufferedSink sink,
Random random) |
Modifier and Type | Method and Description |
---|---|
okio.Sink |
newMessageSink(int formatOpcode)
Stream a message payload as a series of frames.
|
void |
writeClose(int code,
String reason)
Send a close frame with optional code and reason.
|
void |
writePing(okio.Buffer payload)
Send a ping with the supplied
payload . |
void |
writePong(okio.Buffer payload)
Send a pong with the supplied
payload . |
public WebSocketWriter(boolean isClient, okio.BufferedSink sink, Random random)
public void writePing(okio.Buffer payload) throws IOException
payload
. Payload may be null
IOException
public void writePong(okio.Buffer payload) throws IOException
payload
. Payload may be null
IOException
public void writeClose(int code, String reason) throws IOException
code
- Status code as defined by
Section 7.4 of RFC 6455 or
0
.reason
- Reason for shutting down or null
.IOException
public okio.Sink newMessageSink(int formatOpcode)
Copyright © 2017. All rights reserved.