Documentation
¶
Index ¶
- Constants
- func GetMsgData(uuId, msgId, cmd, message string) string
- func GetTextMsgData(uuId, msgId, message string) string
- func GetTextMsgDataEnter(uuId, msgId, message string) string
- func GetTextMsgDataExit(uuId, msgId, message string) string
- type Head
- type HeartBeat
- type Login
- type Message
- type PushMsg
- type Request
- type Response
- type Server
- type UserOnline
Constants ¶
View Source
const ( MessageTypeText = "text" MessageCmdMsg = "msg" MessageCmdEnter = "enter" MessageCmdExit = "exit" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Head ¶
type Head struct {
Seq string `json:"seq"` // 消息的Id
Cmd string `json:"cmd"` // 消息的cmd 动作
Response *Response `json:"response"` // 消息体
}
*********************** 响应数据 *************************
func NewResponseHead ¶
设置返回消息
type Login ¶
type Login struct {
ServiceToken string `json:"serviceToken"` // 验证用户是否登录
AppId uint32 `json:"appId,omitempty"`
UserId string `json:"userId,omitempty"`
}
登录请求数据
type Message ¶
type Message struct {
Target string `json:"target"` // 目标
Type string `json:"type"` // 消息类型 text/img/
Msg string `json:"msg"` // 消息内容
From string `json:"from"` // 发送者
}
消息的定义
type PushMsg ¶
type PushMsg struct {
Seq string `json:"seq"`
Uuid uint64 `json:"uuid"`
Type string `json:"type"`
Msg string `json:"msg"`
}
push 数据结构体
type Request ¶
type Request struct {
Seq string `json:"seq"` // 消息的唯一Id
Cmd string `json:"cmd"` // 请求命令字
Data interface{} `json:"data,omitempty"` // 数据 json
}
*********************** 请求数据 ************************* 通用请求数据格式
type Response ¶
type Server ¶
type UserOnline ¶
type UserOnline struct {
AccIp string `json:"accIp"` // acc Ip
AccPort string `json:"accPort"` // acc 端口
AppId uint32 `json:"appId"` // appId
UserId string `json:"userId"` // 用户Id
ClientIp string `json:"clientIp"` // 客户端Ip
ClientPort string `json:"clientPort"` // 客户端端口
LoginTime uint64 `json:"loginTime"` // 用户上次登录时间
HeartbeatTime uint64 `json:"heartbeatTime"` // 用户上次心跳时间
LogOutTime uint64 `json:"logOutTime"` // 用户退出登录的时间
Qua string `json:"qua"` // qua
DeviceInfo string `json:"deviceInfo"` // 设备信息
IsLogoff bool `json:"isLogoff"` // 是否下线
}
用户在线状态
func UserLogin ¶
func UserLogin(accIp, accPort string, appId uint32, userId string, addr string, loginTime uint64) (userOnline *UserOnline)
用户登录
func (*UserOnline) UserIsLocal ¶
func (u *UserOnline) UserIsLocal(localIp, localPort string) (result bool)
用户是否在本台机器上
Source Files
¶
- msg_model.go
- request_model.go
- response_model.go
- server_model.go
- user_model.go
Click to show internal directories.
Click to hide internal directories.