ws

package
v0.0.0-...-73ddb9c Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelConn

func DelConn(sessionID string) error

DelConn 删除 ConnWrapper,找不到也返回 nil

func WriteToUser

func WriteToUser(userID int64, v interface{}) error

WriteToUser 将信息写给某个 user 的所有 session

Types

type ConnWrapper

type ConnWrapper struct {
	SessionID string
	UserID    int64
	// contains filtered or unexported fields
}

func GetConn

func GetConn(sessionID string) *ConnWrapper

GetConn 获得 ConnWrapper,找不到则返回 nil

func GetConnByUserID

func GetConnByUserID(userID int64) []*ConnWrapper

GetConnByUserID 获得某个 user 的全部 conn

func New

func New(sessionID string, userID int64, conn *websocket.Conn) *ConnWrapper

func PutConn

func PutConn(sessionID string, userID int64, conn *websocket.Conn) *ConnWrapper

PutConn 加入新的 ConnWrapper

func (*ConnWrapper) Close

func (wrapper *ConnWrapper) Close() error

Close 关闭连接,返回 conn.Close 的错误

func (*ConnWrapper) Start

func (wrapper *ConnWrapper) Start()

Start 开始遍历消息队列

func (*ConnWrapper) Write

func (wrapper *ConnWrapper) Write(v interface{}) error

Write 向消息队列中写入 json object 的指针

Jump to

Keyboard shortcuts

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