message

package
v0.0.0-...-2bf1368 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginMesType            = "LoginMes"
	LoginResMesType         = "LoginResMes"
	RegisterMesType         = "RegisterMes"
	RegisterResMesType      = "RegisterResMes"
	NotifyUserStatusMesType = "NotifyUserStatusMes"
	SmsMesType              = "SmsMes"
)
View Source
const (
	UserOnline = iota
	UserOffline
	UserBusyStatus
)

这里我们定义几个用户状态的常量

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginMes

type LoginMes struct {
	UserId   int    `json:"userId"`   //用户id
	UserPwd  string `json:"userPwd"`  //用户密码
	UserName string `json:"userName"` //用户名
}

type LoginResMes

type LoginResMes struct {
	Code    int    `json:"code"` // 返回状态码 500 表示该用户未注册 200表示登录成功
	UsersId []int  // 增加字段,保存用户id的切片
	Error   string `json:"error"` // 返回错误信息
}

type Message

type Message struct {
	Type string `json:"type"` //消息类型
	Data string `json:"data"` //消息的类型
}

type NotifyUserStatusMes

type NotifyUserStatusMes struct {
	UserId int `json:"userId"` //用户id
	Status int `json:"status"` //用户的状态
}

为了配合服务器端推送用户状态变化的消息

type RegisterMes

type RegisterMes struct {
	User User `json:"user"` //类型就是User结构体.
}

type RegisterResMes

type RegisterResMes struct {
	Code  int    `json:"code"`  // 返回状态码 400 表示该用户已经占有 200表示注册成功
	Error string `json:"error"` // 返回错误信息
}

type SmsMes

type SmsMes struct {
	Content string `json:"content"` //内容
	User           //匿名结构体,继承
}

增加一个SmsMes //发送的消息

type User

type User struct {
	//确定字段信息
	//为了序列化和反序列化成功,我们必须保证
	//用户信息的json字符串的key 和 结构体的字段对应的 tag 名字一致!!!
	UserId     int    `json:"userId"`
	UserPwd    string `json:"userPwd"`
	UserName   string `json:"userName"`
	UserStatus int    `json:"userStatus"` //用户状态..
	Sex        string `json:"sex"`        //性别.
}

Jump to

Keyboard shortcuts

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