websocket_v1

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HookEvent

type HookEvent struct {
	EventType string // 事件类型 online / offline / message
	User      *serverUser
	Message   UDataSocket
}

type Server

type Server struct {
	ClientHeartTimeOut int                 // 客户端超时时间 默认60秒
	OnHookEvent        func(Msg HookEvent) // hook回调消息
	ChanHookEvent      chan *HookEvent     // 所有消息,各个子连接传过来的

	SendFlag int // socket验证标记
	// contains filtered or unexported fields
}

1、结构体 -------------------------------------------------------------------------

func NewServer

func NewServer(OnHookEvent func(Msg HookEvent)) *Server

创建一个server的实例

func (*Server) NewUser

func (Me *Server) NewUser(ws *websocket.Conn, S *Server)

处理客户端连接

func (*Server) SendMsg

func (Me *Server) SendMsg(ClientId *string, Msg UDataSocket) error

消息发送

func (*Server) Set added in v1.0.7

func (Me *Server) Set(opt string, value interface{}) *Server

对外函数2:连接服务器

type UDataSocket

type UDataSocket struct {
	CType   int    // 内容类型 1:客户端请求消息 2:服务端表接口消息 4:服务端表内容数据 200:服务端发送结束
	Content []byte // 发送内容
}

结构体1:传输数据上层结构体

Jump to

Keyboard shortcuts

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