public interface WebSocket
OkHttpClient
.
Modifier and Type | Interface and Description |
---|---|
static interface |
WebSocket.Factory |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Immediately and violently release resources held by this web socket, discarding any enqueued
messages.
|
boolean |
close(int code,
String reason)
Attempts to initiate a graceful shutdown of this web socket.
|
long |
queueSize()
Returns the size in bytes of all messages enqueued to be transmitted to the server.
|
Request |
request()
Returns the original request that initiated this web socket.
|
boolean |
send(okio.ByteString bytes)
Attempts to enqueue
bytes to be sent as a the data of a binary (type 0x2 )
message. |
boolean |
send(String text)
Attempts to enqueue
text to be UTF-8 encoded and sent as a the data of a text (type
0x1 ) message. |
Request request()
long queueSize()
boolean send(String text)
text
to be UTF-8 encoded and sent as a the data of a text (type
0x1
) message.
This method returns true if the message was enqueued. Messages that would overflow the outgoing message buffer will be rejected and trigger a graceful shutdown of this web socket. This method returns false in that case, and in any other case where this web socket is closing, closed, or canceled.
This method returns immediately.
boolean send(okio.ByteString bytes)
bytes
to be sent as a the data of a binary (type 0x2
)
message.
This method returns true if the message was enqueued. Messages that would overflow the outgoing message buffer (16 MiB) will be rejected and trigger a graceful shutdown of this web socket. This method returns false in that case, and in any other case where this web socket is closing, closed, or canceled.
This method returns immediately.
boolean close(int code, @Nullable String reason)
send(java.lang.String)
will
return false and their messages will not be enqueued.
This returns true if a graceful shutdown was initiated by this call. It returns false if a graceful shutdown was already underway or if the web socket is already closed or canceled.
code
- Status code as defined by Section 7.4 of RFC 6455.reason
- Reason for shutting down or null
.IllegalArgumentException
- if code is invalid.void cancel()
Copyright © 2019. All rights reserved.