public interface WebSocket
| Modifier and Type | Interface and Description |
|---|---|
static interface |
WebSocket.Factory |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
立即并强烈地释放这个web套接字持有的资源,丢弃任何排队的消息。
如果web套接字已经关闭或取消,则此操作不执行任何操作.
|
boolean |
close(int code,
String reason)
尝试启动此web套接字的正常关闭。任何已加入队列的消息将在发送关闭消息之前发送,
但是随后对
send(java.lang.String)的调用将返回false,它们的消息将不被加入队列. |
long |
queueSize() |
Request |
request() |
boolean |
send(ByteString bytes)
尝试将
bytes作为二进制(类型为0x2)消息的数据发送
如果消息被加入队列,此方法将返回true。将溢出传出消息缓冲区(16 MiB)的消息将被拒绝,
并触发此web套接字的graceful shutdown。此方法在这种情况下返回false,
在此web套接字关闭、关闭或取消的任何其他情况下也返回false |
boolean |
send(String text)
尝试将
text编码为UTF-8并将其作为文本(类型为0x1)消息的数据发送
如果消息被加入队列,此方法将返回true。将溢出传出消息缓冲区的消息将被拒绝,
并触发此web套接字的graceful shutdown。此方法在这种情况下返回false,
在此web套接字关闭、关闭或取消的任何其他情况下也返回false |
Request request()
long queueSize()
boolean send(String text)
text编码为UTF-8并将其作为文本(类型为0x1)消息的数据发送
如果消息被加入队列,此方法将返回true。将溢出传出消息缓冲区的消息将被拒绝,
并触发此web套接字的graceful shutdown。此方法在这种情况下返回false,
在此web套接字关闭、关闭或取消的任何其他情况下也返回falsetext - 文本信息boolean send(ByteString bytes)
bytes作为二进制(类型为0x2)消息的数据发送
如果消息被加入队列,此方法将返回true。将溢出传出消息缓冲区(16 MiB)的消息将被拒绝,
并触发此web套接字的graceful shutdown。此方法在这种情况下返回false,
在此web套接字关闭、关闭或取消的任何其他情况下也返回falsebytes - 缓存流boolean close(int code,
String reason)
send(java.lang.String)的调用将返回false,它们的消息将不被加入队列.code - RFC 6455第7.4节定义的状态码reason - 关闭或null的原因IllegalArgumentException - 如果状态码无效.void cancel()
Copyright © 2020. All rights reserved.