swebsocket

package
v0.0.0-...-f1241d1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MulanPSL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseHandler

type ResponseHandler = func(msg []byte, conn *ServerConn)

type ServerConn

type ServerConn struct {
	WSMutex sync.Mutex       // WS写锁
	WS      *websocket.Conn  // websocket连接
	Exit    chan bool        //退出
	Flag    bool             //判断websocket是否已经关闭
	Receive chan []byte      //接收客户端的数据
	Send    chan interface{} //发送数据

	MessageType int
	// contains filtered or unexported fields
}

func CreateConn

func CreateConn(wsConn *websocket.Conn, MessageType int) (*ServerConn, error)

CreateConn 创建连接

func (*ServerConn) CloseConn

func (conn *ServerConn) CloseConn()

关闭连接

func (*ServerConn) Handle

func (conn *ServerConn) Handle(res ResponseHandler)

func (*ServerConn) SendMessage

func (conn *ServerConn) SendMessage(msg []byte)

SendMessage 发送消息

func (*ServerConn) WriteReadLoop

func (conn *ServerConn) WriteReadLoop()

读写数据

Jump to

Keyboard shortcuts

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