websocket

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	/*
	 * 文本帧类型
	 * 0 0 0 0 0 0 0 1
	 */
	TextMessage = 1
	/*
	 * 关闭数据帧类型
	 * 0 0 0 0 1 0 0 0
	 */
	CloseMessage = 8
)

Variables

View Source
var KeyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")

Functions

This section is empty.

Types

type Client added in v1.1.0

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v1.1.0

func NewClient(url string) (*Client, error)

NewCient new http client NewClient("http://10.0.2.15:8080/")

func (*Client) Close added in v1.1.0

func (c *Client) Close()

func (*Client) Push added in v1.1.0

func (c *Client) Push(data string) error

Push push to websocket server data

func (*Client) Recv added in v1.1.0

func (c *Client) Recv() (string, error)

Recv recvData

func (*Client) Upgrade added in v1.1.0

func (c *Client) Upgrade() error

Upgrade http 协议升级为websocket协议 GET /path HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protcol: chat, superchat Sec-WebSocket-Version: 13

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

websocket 连接

func Upgrade

func Upgrade(r *http.Request, w *http.Response) (c *Conn, err error)

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) ReadData

func (c *Conn) ReadData() (data []byte, err error)

读取数据

func (*Conn) SendData

func (c *Conn) SendData(data []byte) error

发送数据

Jump to

Keyboard shortcuts

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