websocket

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerWrap

type HandlerWrap struct {
	Upgrade *ws.Upgrader
	// contains filtered or unexported fields
}

HandlerWrap gev Handler wrap

func NewHandlerWrap

func NewHandlerWrap(u *ws.Upgrader, wsHandler WSHandler) *HandlerWrap

NewHandlerWrap websocket handler wrap

func (*HandlerWrap) OnClose

func (s *HandlerWrap) OnClose(c *connection.Connection)

OnClose wrap

func (*HandlerWrap) OnConnect

func (s *HandlerWrap) OnConnect(c *connection.Connection)

OnConnect wrap

func (*HandlerWrap) OnMessage

func (s *HandlerWrap) OnMessage(c *connection.Connection, ctx interface{}, payload []byte) []byte

OnMessage wrap

type Protocol

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

Protocol websocket

func New

func New(u *ws.Upgrader) *Protocol

New 创建 websocket Protocol

func (*Protocol) Packet

func (p *Protocol) Packet(c *connection.Connection, data []byte) []byte

Packet 直接返回

func (*Protocol) UnPacket

func (p *Protocol) UnPacket(c *connection.Connection, buffer *ringbuffer.RingBuffer) (ctx interface{}, out []byte)

UnPacket 解析 websocket 协议,返回 header ,payload

type WSHandler

type WSHandler interface {
	OnConnect(c *connection.Connection)
	OnMessage(c *connection.Connection, msg []byte) (ws.MessageType, []byte)
	OnClose(c *connection.Connection)
}

WSHandler WebSocket Server 注册接口

Directories

Path Synopsis
ws

Jump to

Keyboard shortcuts

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