server

package
v0.0.0-...-62f90f5 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWsServer

func NewWsServer() *socketio.Server

Types

type ConfirmMsg

type ConfirmMsg struct {
	MsgId string
	Conn  socketio.Conn
}

用于客户端返回确认接收消息后同步数据

type ConfirmMsgWorker

type ConfirmMsgWorker struct {
	ConfirmMsgChanPool chan chan *ConfirmMsg
	// contains filtered or unexported fields
}

接收客户端消息回执的worker

type ConnRoomChangeInfo

type ConnRoomChangeInfo struct {
	Room string
	Conn socketio.Conn
}

用于离开和加入房间时通过通道同步数据

type EnsureMsgSendInfo

type EnsureMsgSendInfo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type MsgDispatcher

type MsgDispatcher struct {
	ConfirmMsgChan     chan *ConfirmMsg //客户端消息确认同步通道
	ConfirmMsgChanPool chan chan *ConfirmMsg

	EnsureMsgSendMap map[string]*EnsureMsgSendInfo //存放消息的id和客户端id的映射,以及该发送给该客户端发送消息的时间
	// contains filtered or unexported fields
}

func NewMsgDispatcher

func NewMsgDispatcher(msgWorkerNum, confirmMsgWorkerNum, reSendWorkerNum int) *MsgDispatcher

创建消息分发器,并初始化消息工作者

type MsgManager

type MsgManager struct {
	JoinRoomChan     chan *ConnRoomChangeInfo //离开房间的通信通道
	LeavaRoomChan    chan *ConnRoomChangeInfo //进入房间的通信通道
	LeaveAllRoomChan chan socketio.Conn       //用于客户端异常断开等情况退出所有房间
	// contains filtered or unexported fields
}

func GetMsgManager

func GetMsgManager() *MsgManager

func (*MsgManager) ConfirmMsg

func (s *MsgManager) ConfirmMsg(conn socketio.Conn, msgId string)

func (*MsgManager) DispatchMsg

func (s *MsgManager) DispatchMsg(room, postData, isEnsure string)

func (*MsgManager) JoinRoom

func (s *MsgManager) JoinRoom(room string, conn socketio.Conn)

func (*MsgManager) LeaveAllRoom

func (s *MsgManager) LeaveAllRoom(conn socketio.Conn)

func (*MsgManager) LeaveRoom

func (s *MsgManager) LeaveRoom(room string, conn socketio.Conn)

func (*MsgManager) RoomHasConn

func (s *MsgManager) RoomHasConn(room string, conn socketio.Conn) bool

检查某一个链接是否在某一个房间内

func (*MsgManager) Run

func (s *MsgManager) Run()

type MsgRoom

type MsgRoom struct {
	Name     string
	ConnsMap sync.Map //健名为conn.id,键值为conn
	// contains filtered or unexported fields
}

func (*MsgRoom) HasConn

func (mr *MsgRoom) HasConn(conn socketio.Conn) bool

func (*MsgRoom) LeaveRoom

func (mr *MsgRoom) LeaveRoom(conn socketio.Conn)

type MsgWorker

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

发送消息的worker

type PostMsg

type PostMsg struct {
	Id       string      `json:"msgId"`    //消息id,用于ws客户端和服务器确认收到该消息
	Room     string      `json:"room"`     //房间号
	PostData interface{} `json:"postData"` //接口收到的数据,原样转发给ws客户端
	IsEnsure bool        `json:"isEnsure"` //是否需要保证成功送达
}

type ReSendMsgWorker

type ReSendMsgWorker struct {
	ReSendMsgChan  chan []string //用于接收ws客户端发送的确认消息回执
	ReSendChanPool chan chan []string
	// contains filtered or unexported fields
}

接收客户端消息回执的worker

type RingQueue

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

func NewRingQueue

func NewRingQueue(queueLength int, popChan chan []string) *RingQueue

func (*RingQueue) Add

func (rq *RingQueue) Add(sec int, msgId string)

将新任务加入环形队列

func (*RingQueue) Run

func (rq *RingQueue) Run()

启动并开启定时器,一秒钟处理一次消息

Jump to

Keyboard shortcuts

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