Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConnectionClosedError = fmt.Errorf("websocket connection closed")
ConnectionClosedError Websocket未连接错误
View Source
var Endpoint = "wss://api.huobi.pro/ws"
Endpoint 行情的Websocket入口
View Source
var SafeWebSocketDestroyError = fmt.Errorf("connection destroy by user")
Functions ¶
This section is empty.
Types ¶
type Market ¶
type Market struct { // 主动发送心跳的时间间隔,默认5秒 HeartbeatInterval time.Duration // 接收消息超时时间,默认10秒 ReceiveTimeout time.Duration // contains filtered or unexported fields }
type SafeWebSocket ¶ added in v1.0.3
type SafeWebSocket struct {
// contains filtered or unexported fields
}
SafeWebSocket 安全的WebSocket封装 保证读取和发送操作是并发安全的,支持自定义保持alive函数
func NewSafeWebSocket ¶ added in v1.0.3
func NewSafeWebSocket(endpoint string) (*SafeWebSocket, error)
NewSafeWebSocket 创建安全的WebSocket实例并连接
func (*SafeWebSocket) Destroy ¶ added in v1.0.3
func (s *SafeWebSocket) Destroy() (err error)
Destroy 销毁
func (*SafeWebSocket) KeepAlive ¶ added in v1.0.3
func (s *SafeWebSocket) KeepAlive(v time.Duration, h SafeWebSocketAliveHandler)
KeepAlive 设置alive周期及函数
func (*SafeWebSocket) Listen ¶ added in v1.0.3
func (s *SafeWebSocket) Listen(h SafeWebSocketMessageListener)
Listen 监听消息
func (*SafeWebSocket) Loop ¶ added in v1.0.3
func (s *SafeWebSocket) Loop() error
Loop 进入事件循环,直到连接关闭才退出
type SafeWebSocketAliveHandler ¶ added in v1.0.3
type SafeWebSocketAliveHandler = func()
type SafeWebSocketMessageListener ¶ added in v1.0.3
type SafeWebSocketMessageListener = func(b []byte)
Click to show internal directories.
Click to hide internal directories.