Documentation
¶
Index ¶
- Variables
- type Handler
- type Handler2
- type HandlerMessage
- type PbType
- type PbType2
- type SocketInterface
- type SocketV1
- func (s *SocketV1) BindUid(conn *WebsocketData, uid int64, guid string)
- func (s *SocketV1) IsOnline(uid int64) bool
- func (s *SocketV1) JoinGroup(conn *WebsocketData, group string)
- func (s *SocketV1) LeaveGroup(conn *WebsocketData, group string)
- func (s *SocketV1) Load(serv *ghttp.Server, prefix string)
- func (s *SocketV1) OnClose(conn *WebsocketData)
- func (s *SocketV1) OnConnect(ctx context.Context, ws *websocket.Conn)
- func (s *SocketV1) OnMessage(conn *WebsocketData, req []byte, msgType int)
- func (s *SocketV1) RegisterByte2Pb(_func PbType)
- func (s *SocketV1) RegisterMessage(_func HandlerMessage)
- func (s *SocketV1) RegisterOnClose(_func Handler2)
- func (s *SocketV1) RegisterOnConnect(_func Handler2)
- func (s *SocketV1) RegisterPb2Byte(_func PbType2)
- func (s *SocketV1) RegisterRouter(cmd int, handler Handler)
- func (s *SocketV1) Send(cmd int32, uid int64, req proto.Message)
- func (s *SocketV1) SendAll(cmd int32, req proto.Message)
- func (s *SocketV1) SendGroup(cmd int32, roomId string, req proto.Message)
- func (s *SocketV1) SendUuid(cmd int32, uuidStr string, req proto.Message)
- func (s *SocketV1) Uid2Uuid(uid int64) (uuid string)
- func (s *SocketV1) UnBindUid(uid int64)
- type WebsocketData
Constants ¶
This section is empty.
Variables ¶
View Source
var ( OnConnectHandlers = make([]Handler2, 0) OnCloseHandlers = make([]Handler2, 0) Byte2Pb = make([]PbType, 0) Pb2Bytes = make([]PbType2, 0) )
路由器的处理映射
Functions ¶
This section is empty.
Types ¶
type Handler2 ¶ added in v1.2.11
type Handler2 func(conn *WebsocketData)
type HandlerMessage ¶ added in v1.2.11
type HandlerMessage func(conn *WebsocketData, req any)
type SocketInterface ¶
type SocketV1 ¶
type SocketV1 struct {
Type int `json:"type"`
}
func (*SocketV1) BindUid ¶ added in v1.2.11
func (s *SocketV1) BindUid(conn *WebsocketData, uid int64, guid string)
绑定用户编号
func (*SocketV1) JoinGroup ¶ added in v1.2.12
func (s *SocketV1) JoinGroup(conn *WebsocketData, group string)
加入群组
func (*SocketV1) LeaveGroup ¶ added in v1.2.12
func (s *SocketV1) LeaveGroup(conn *WebsocketData, group string)
退出群组
func (*SocketV1) OnClose ¶
func (s *SocketV1) OnClose(conn *WebsocketData)
OnClose
@Description: @receiver s @param conn
func (*SocketV1) OnMessage ¶
func (s *SocketV1) OnMessage(conn *WebsocketData, req []byte, msgType int)
OnMessage
@Description: @receiver s @param msg @param msgType
func (*SocketV1) RegisterByte2Pb ¶ added in v1.2.11
func (*SocketV1) RegisterMessage ¶ added in v1.2.11
func (s *SocketV1) RegisterMessage(_func HandlerMessage)
注册方法长连接消息体
func (*SocketV1) RegisterOnClose ¶ added in v1.2.10
func (*SocketV1) RegisterOnConnect ¶ added in v1.2.10
注册方法,讲长连接登陆方法进行注册
func (*SocketV1) RegisterPb2Byte ¶ added in v1.2.11
func (*SocketV1) RegisterRouter ¶
注册方法,将某个消息路由器ID和对应的处理方法关联起来
func (*SocketV1) SendUuid ¶ added in v1.2.11
SendUuid
@Description: @receiver s @param uid @param data
type WebsocketData ¶
type WebsocketData struct {
Ws *websocket.Conn `json:"ws" dc:"websocket连接池"`
Uuid string `json:"uuid" dc:"用户唯一标识"`
Uid int64 `json:"uid" dc:"用户编号"`
Guid string `json:"guid" dc:"用户凭证"`
Groups []string `json:"groups" dc:"群组"`
Ctx context.Context `json:"ctx" dc:""`
RoomId string `json:"roomId" dc:"房间编号"`
}
Click to show internal directories.
Click to hide internal directories.