gowsclient

package module
v0.0.0-...-da8852b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 5 Imported by: 0

README

gowsclient

golang 使用 gorilla/websocket 封装client,使得websocket客户端更易用,更强壮。

这是对websocket的轻量级封装,解决一些典型问题。包含keepalive,autoReconnect,loop read message,write message串行化。以及onConnected onReceive 事件的封装,使用方法见client_test.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	OnConnect func()
	OnReceive func(msg *Message)
	// contains filtered or unexported fields
}

func New

func New(rawUrl string) (*Client, error)

func NewWithHeader

func NewWithHeader(rawUrl string, header *http.Header) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect()

func (*Client) WriteMessage

func (c *Client) WriteMessage(msg *Message)

type Message

type Message struct {
	Mt      int
	Message []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL