2021-04-22 06:12:35 +00:00
|
|
|
package message
|
|
|
|
|
|
|
|
import (
|
2021-04-25 01:53:49 +00:00
|
|
|
"chat/user"
|
2021-04-22 06:12:35 +00:00
|
|
|
"reflect"
|
|
|
|
)
|
|
|
|
|
|
|
|
var MsgType = map[string]reflect.Type{
|
|
|
|
"login_send": reflect.TypeOf(&LoginS{}).Elem(),
|
|
|
|
"login_response": reflect.TypeOf(&Correspond{}).Elem(),
|
2021-04-25 01:53:49 +00:00
|
|
|
"add_user": reflect.TypeOf(&user.User{}).Elem(),
|
2021-04-28 08:16:18 +00:00
|
|
|
"user_message": reflect.TypeOf(&UserMessage{}).Elem(),
|
|
|
|
"online_users": reflect.TypeOf(&UsersPres{}).Elem(),
|
2021-04-22 06:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Message struct {
|
|
|
|
//Id int
|
2021-04-28 08:16:18 +00:00
|
|
|
Type string `json:"type"`
|
|
|
|
Code int `json:"code"`
|
|
|
|
Msg string `json:"msg"`
|
|
|
|
Data interface{} `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UsersPres struct {
|
|
|
|
Data []UserPre
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserPre struct {
|
|
|
|
Id int `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserMessage struct {
|
|
|
|
FromUid int
|
|
|
|
FromUserName string
|
|
|
|
TotUid int
|
|
|
|
Msg string
|
2021-04-29 08:27:19 +00:00
|
|
|
Datetime string
|
2021-04-22 06:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LoginS struct {
|
|
|
|
Uid int
|
|
|
|
Pw string
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Correspond struct {
|
|
|
|
Code int
|
|
|
|
Msg string
|
|
|
|
Error string
|
2021-04-28 08:16:18 +00:00
|
|
|
User user.User
|
2021-04-22 06:12:35 +00:00
|
|
|
}
|