ws

package
v0.0.0-...-c6e4f4a Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MulanPSL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSeqno

func NewSeqno() string

Types

type ConnContext

type ConnContext struct {
	Conn   *websocket.Conn
	Server *Server
	Error  error
	// contains filtered or unexported fields
}

func (*ConnContext) Abort

func (c *ConnContext) Abort()

func (*ConnContext) AbortWithError

func (c *ConnContext) AbortWithError(err error)

func (*ConnContext) Context

func (c *ConnContext) Context() context.Context

func (*ConnContext) IsAborted

func (c *ConnContext) IsAborted() bool

func (*ConnContext) Next

func (c *ConnContext) Next()

func (*ConnContext) WithContext

func (c *ConnContext) WithContext(ctx context.Context) *ConnContext

type ConnHandler

type ConnHandler func(c *ConnContext)

type Group

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

func (*Group) Group

func (g *Group) Group(handlers ...MessageHandler) *Group

func (*Group) OnCmd

func (g *Group) OnCmd(cmd string, handlers ...MessageHandler)

type MessageBody

type MessageBody struct {
	Cmd   string          `json:"cmd"`
	Seqno string          `json:"seqno,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
}

type MessageContext

type MessageContext struct {
	Conn        *websocket.Conn
	MessageType int
	Message     []byte
	JsonBody    *MessageBody
	Server      *Server
	Error       error
	// contains filtered or unexported fields
}

func (*MessageContext) Abort

func (c *MessageContext) Abort()

func (*MessageContext) AbortWithError

func (c *MessageContext) AbortWithError(err error)

func (*MessageContext) Context

func (c *MessageContext) Context() context.Context

func (*MessageContext) IsAborted

func (c *MessageContext) IsAborted() bool

func (*MessageContext) Next

func (c *MessageContext) Next()

func (*MessageContext) ShouldBindJson

func (c *MessageContext) ShouldBindJson(v interface{}) error

func (*MessageContext) WithContext

func (c *MessageContext) WithContext(ctx context.Context) *MessageContext

func (*MessageContext) WriteMessage

func (c *MessageContext) WriteMessage(data []byte) error

type MessageHandler

type MessageHandler func(ctx *MessageContext)

func Timeout

func Timeout() MessageHandler

type RespBody

type RespBody struct {
	Cmd   string      `json:"cmd"`
	Seqno string      `json:"seqno,omitempty"`
	Code  int         `json:"code"`
	Msg   string      `json:"msg"`
	Data  interface{} `json:"data,omitempty"`
}

type SendBody

type SendBody struct {
	Cmd   string      `json:"cmd"`
	Seqno string      `json:"seqno,omitempty"`
	Data  interface{} `json:"data,omitempty"`
}

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Group

func (s *Server) Group(handlers ...MessageHandler) *Group

func (*Server) OnCmd

func (s *Server) OnCmd(cmd string, handlers ...MessageHandler)

func (*Server) OnConnect

func (s *Server) OnConnect(handlers ...ConnHandler)

func (*Server) Upgrade

func (s *Server) Upgrade(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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