websocketer

package
v0.0.0-...-ee2a228 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NORMAL = iota // 定义心跳的情况,NORMAL 正常的情况
	CLOSE         // 关闭心跳检测机制
)

Variables

View Source
var (
	OnOpen    func(*Server, *websocket.Conn)
	OnMessage func(*Server, *Frame)
	OnClose   func(*Server, *websocket.Conn)

	OnHandsheke func(conn *websocket.Config, r *http.Request) error

	HeartbeatCheckInterval int  = 0
	Req                    byte = 0
	Heartbeat              byte = 1
)

目的是为了封装websocket之后能够很好地调用我们的服务的操作

Functions

func Close

func Close(conn *websocket.Conn)

func RecJson

func RecJson(conn *websocket.Conn, v interface{})

接收json数据包

func SendJson

func SendJson(conn *websocket.Conn, v interface{})

发送json数据包

Types

type Frame

type Frame struct {
	Data string
}

type Server

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

func NewServer

func NewServer(addr, uri string) *Server

func (*Server) Conn

func (ser *Server) Conn() *websocket.Conn

func (*Server) Run

func (ser *Server) Run()

func (*Server) Send

func (ser *Server) Send(v interface{})

Jump to

Keyboard shortcuts

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