IWebSocket

interface IWebSocket

WebSocket

Author

Jenly

Follow me

Inheritors

Functions

Link copied to clipboard
abstract fun addHeader(name: String, value: String)

添加请求头;需在调用connect函数之前添加请求头才有效

Link copied to clipboard
abstract fun close(): Boolean
abstract fun close(code: Int, reason: String): Boolean

关闭

Link copied to clipboard
abstract fun connect()

连接

Link copied to clipboard
abstract fun getReadyState(): ReadyState

获取WebSocket的连接状态;更多详细状态可参见:ReadyState

Link copied to clipboard
abstract fun isClosed(): Boolean

是否已经关闭;更多详细状态可参见:ReadyState

Link copied to clipboard
abstract fun isClosing(): Boolean

是否正在关闭中;更多详细状态可参见:ReadyState

Link copied to clipboard
abstract fun isOpen(): Boolean

连接是否已打开;更多详细状态可参见:ReadyState

Link copied to clipboard
abstract fun reconnect()

重新连接

Link copied to clipboard
abstract fun removeHeader(name: String)

移除请求头;需在调用connect函数之前移除请求头才有效

Link copied to clipboard
abstract fun send(text: String): Boolean

发送消息;文本消息(类型:0x01)

abstract fun send(bytes: ByteString): Boolean

发送消息;二进制消息(类型:0x02)

Link copied to clipboard
abstract fun setWebSocketListener(listener: WebSocketListener?)

设置WebSocket监听