go_ws

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 8 Imported by: 0

README

go-ws

go版本ws服务器与客户端

Documentation

Index

Constants

View Source
const (
	CLIENT service = 1 << 0 //标记为客户端
	SERVER service = 1 << 1 //标记为服务端
)

Variables

This section is empty.

Functions

func NewWebsocket

func NewWebsocket(opts ...Option) (cl *client)

获取ws对象

Types

type CheckOriginFunc

type CheckOriginFunc func(r *http.Request, ctx *Context) bool

type Context

type Context struct {
	Ctx     context.Context
	Storage storage
	// contains filtered or unexported fields
}

func (*Context) ForthwithSend

func (c *Context) ForthwithSend(payload []byte) (err error)

func (*Context) LaterSend

func (c *Context) LaterSend(payload []byte) (err error)

稍后推送 -- 需要推送数量过多时 延后推送的数据

type Option

type Option func(e *Options)

func WithClientWsUrl

func WithClientWsUrl(u *url.URL, requestHeader http.Header) Option

func WithServerAuth

func WithServerAuth(fn CheckOriginFunc) Option

func WithServerHttp

func WithServerHttp(w http.ResponseWriter, r *http.Request) Option

type Options

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

配置文件

Jump to

Keyboard shortcuts

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