This commit is contained in:
azw 2023-08-20 18:28:35 +08:00
commit c7b7838c9b
18 changed files with 1236 additions and 828 deletions

3
.gitignore vendored
View File

@ -17,4 +17,5 @@ __pycache__
node_modules/
nohup.out
bin/
.idea
.idea
.vscode

16
server/guildserver/go.sum Normal file
View File

@ -0,0 +1,16 @@
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=

16
server/hallserver/go.sum Normal file
View File

@ -0,0 +1,16 @@
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=

View File

@ -5,25 +5,20 @@ import (
proto "github.com/golang/protobuf/proto"
)
type CsNetMsgHandler f5.NetMsgHandler[MsgHandler];
type MsgHandlerImpl struct {
}
type NetMsgHandler struct {
MsgId int
HandlerId int
parseCb func([]byte) interface{}
cb func(*f5.MsgHdr, MsgHandler)
}
var handlers [2000]*CsNetMsgHandler
var handlers [2000]*NetMsgHandler
func GetNetMsgHandler(msgId uint16) *NetMsgHandler {
func GetNetMsgHandler(msgId uint16) *CsNetMsgHandler {
handler := handlers[msgId]
return handler
}
func DispatchMsg(handler *NetMsgHandler, hdr *f5.MsgHdr, msgHandler MsgHandler) {
handler.cb(hdr, msgHandler)
func DispatchMsg(handler *CsNetMsgHandler, hdr *f5.MsgHdr, msgHandler MsgHandler) {
handler.Cb(hdr, msgHandler)
}
func RegHandlerId(msgId int, handlerId int) {
@ -36,18 +31,21 @@ func ParsePb(msgId uint16, data []byte) interface{} {
if handler == nil {
return nil
}
return handler.parseCb(data)
return handler.ParseCb(data)
}
type MsgHandler interface {
CMPing(*f5.MsgHdr, *CMPing)
CMLogin(*f5.MsgHdr, *CMLogin)
CMReconnect(*f5.MsgHdr, *CMReconnect)
CMSearchFriend(*f5.MsgHdr, *CMSearchFriend)
CMListPendingFriendRequest(*f5.MsgHdr, *CMListPendingFriendRequest)
CMSearchUser(*f5.MsgHdr, *CMSearchUser)
CMSearchUserByAccountId(*f5.MsgHdr, *CMSearchUserByAccountId)
CMAddFriendRequest(*f5.MsgHdr, *CMAddFriendRequest)
CMAcceptFriendRequest(*f5.MsgHdr, *CMAcceptFriendRequest)
CMRejectFriendRequest(*f5.MsgHdr, *CMRejectFriendRequest)
CMListPendingFriendRequest(*f5.MsgHdr, *CMListPendingFriendRequest)
CMListFriend(*f5.MsgHdr, *CMListFriend)
CMDeleteFriendShip(*f5.MsgHdr, *CMDeleteFriendShip)
}
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
@ -59,10 +57,10 @@ func (this *MsgHandlerImpl) CMLogin(hdr *f5.MsgHdr, msg *CMLogin) {
func (this *MsgHandlerImpl) CMReconnect(hdr *f5.MsgHdr, msg *CMReconnect) {
}
func (this *MsgHandlerImpl) CMSearchFriend(hdr *f5.MsgHdr, msg *CMSearchFriend) {
func (this *MsgHandlerImpl) CMSearchUser(hdr *f5.MsgHdr, msg *CMSearchUser) {
}
func (this *MsgHandlerImpl) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *CMListPendingFriendRequest) {
func (this *MsgHandlerImpl) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *CMSearchUserByAccountId) {
}
func (this *MsgHandlerImpl) CMAddFriendRequest(hdr *f5.MsgHdr, msg *CMAddFriendRequest) {
@ -71,9 +69,18 @@ func (this *MsgHandlerImpl) CMAddFriendRequest(hdr *f5.MsgHdr, msg *CMAddFriendR
func (this *MsgHandlerImpl) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *CMAcceptFriendRequest) {
}
func (this *MsgHandlerImpl) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *CMRejectFriendRequest) {
}
func (this *MsgHandlerImpl) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *CMListPendingFriendRequest) {
}
func (this *MsgHandlerImpl) CMListFriend(hdr *f5.MsgHdr, msg *CMListFriend) {
}
func (this *MsgHandlerImpl) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *CMDeleteFriendShip) {
}
func (this *CMPing) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMPing)
}
@ -102,20 +109,20 @@ func (this *SMReconnect) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMReconnect)
}
func (this *CMSearchFriend) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSearchFriend)
func (this *CMSearchUser) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSearchUser)
}
func (this *SMSearchFriend) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMSearchFriend)
func (this *SMSearchUser) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMSearchUser)
}
func (this *CMListPendingFriendRequest) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMListPendingFriendRequest)
func (this *CMSearchUserByAccountId) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSearchUserByAccountId)
}
func (this *SMListPendingFriendRequest) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMListPendingFriendRequest)
func (this *SMSearchUserByAccountId) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMSearchUserByAccountId)
}
func (this *CMAddFriendRequest) GetNetMsgId() uint16 {
@ -134,6 +141,22 @@ func (this *SMAcceptFriendRequest) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMAcceptFriendRequest)
}
func (this *CMRejectFriendRequest) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMRejectFriendRequest)
}
func (this *SMRejectFriendRequest) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRejectFriendRequest)
}
func (this *CMListPendingFriendRequest) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMListPendingFriendRequest)
}
func (this *SMListPendingFriendRequest) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMListPendingFriendRequest)
}
func (this *CMListFriend) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMListFriend)
}
@ -142,102 +165,146 @@ func (this *SMListFriend) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMListFriend)
}
func (this *CMDeleteFriendShip) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMDeleteFriendShip)
}
func (this *SMDeleteFriendShip) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMDeleteFriendShip)
}
func init() {
handlers[int(CMMessageIdE__CMPing)] = &NetMsgHandler{
handlers[int(CMMessageIdE__CMPing)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMPing),
parseCb: func (data []byte) interface{} {
ParseCb: func (data []byte) interface{} {
msg := &CMPing{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMPing(hdr, hdr.Msg.(*CMPing))
},
}
handlers[int(CMMessageIdE__CMLogin)] = &NetMsgHandler{
handlers[int(CMMessageIdE__CMLogin)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMLogin),
parseCb: func (data []byte) interface{} {
ParseCb: func (data []byte) interface{} {
msg := &CMLogin{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMLogin(hdr, hdr.Msg.(*CMLogin))
},
}
handlers[int(CMMessageIdE__CMReconnect)] = &NetMsgHandler{
handlers[int(CMMessageIdE__CMReconnect)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMReconnect),
parseCb: func (data []byte) interface{} {
ParseCb: func (data []byte) interface{} {
msg := &CMReconnect{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMReconnect(hdr, hdr.Msg.(*CMReconnect))
},
}
handlers[int(CMMessageIdE__CMSearchFriend)] = &NetMsgHandler{
MsgId: int(CMMessageIdE__CMSearchFriend),
parseCb: func (data []byte) interface{} {
msg := &CMSearchFriend{}
handlers[int(CMMessageIdE__CMSearchUser)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSearchUser),
ParseCb: func (data []byte) interface{} {
msg := &CMSearchUser{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSearchFriend(hdr, hdr.Msg.(*CMSearchFriend))
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSearchUser(hdr, hdr.Msg.(*CMSearchUser))
},
}
handlers[int(CMMessageIdE__CMListPendingFriendRequest)] = &NetMsgHandler{
MsgId: int(CMMessageIdE__CMListPendingFriendRequest),
parseCb: func (data []byte) interface{} {
msg := &CMListPendingFriendRequest{}
handlers[int(CMMessageIdE__CMSearchUserByAccountId)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSearchUserByAccountId),
ParseCb: func (data []byte) interface{} {
msg := &CMSearchUserByAccountId{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMListPendingFriendRequest(hdr, hdr.Msg.(*CMListPendingFriendRequest))
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSearchUserByAccountId(hdr, hdr.Msg.(*CMSearchUserByAccountId))
},
}
handlers[int(CMMessageIdE__CMAddFriendRequest)] = &NetMsgHandler{
handlers[int(CMMessageIdE__CMAddFriendRequest)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMAddFriendRequest),
parseCb: func (data []byte) interface{} {
ParseCb: func (data []byte) interface{} {
msg := &CMAddFriendRequest{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMAddFriendRequest(hdr, hdr.Msg.(*CMAddFriendRequest))
},
}
handlers[int(CMMessageIdE__CMAcceptFriendRequest)] = &NetMsgHandler{
handlers[int(CMMessageIdE__CMAcceptFriendRequest)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMAcceptFriendRequest),
parseCb: func (data []byte) interface{} {
ParseCb: func (data []byte) interface{} {
msg := &CMAcceptFriendRequest{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMAcceptFriendRequest(hdr, hdr.Msg.(*CMAcceptFriendRequest))
},
}
handlers[int(CMMessageIdE__CMListFriend)] = &NetMsgHandler{
handlers[int(CMMessageIdE__CMRejectFriendRequest)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMRejectFriendRequest),
ParseCb: func (data []byte) interface{} {
msg := &CMRejectFriendRequest{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMRejectFriendRequest(hdr, hdr.Msg.(*CMRejectFriendRequest))
},
}
handlers[int(CMMessageIdE__CMListPendingFriendRequest)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMListPendingFriendRequest),
ParseCb: func (data []byte) interface{} {
msg := &CMListPendingFriendRequest{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMListPendingFriendRequest(hdr, hdr.Msg.(*CMListPendingFriendRequest))
},
}
handlers[int(CMMessageIdE__CMListFriend)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMListFriend),
parseCb: func (data []byte) interface{} {
ParseCb: func (data []byte) interface{} {
msg := &CMListFriend{}
proto.Unmarshal(data, msg)
return msg
},
cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMListFriend(hdr, hdr.Msg.(*CMListFriend))
},
}
handlers[int(CMMessageIdE__CMDeleteFriendShip)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMDeleteFriendShip),
ParseCb: func (data []byte) interface{} {
msg := &CMDeleteFriendShip{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMDeleteFriendShip(hdr, hdr.Msg.(*CMDeleteFriendShip))
},
}
}

View File

@ -27,11 +27,14 @@ const (
CMMessageIdE__CMPing CMMessageIdE = 101
CMMessageIdE__CMLogin CMMessageIdE = 103
CMMessageIdE__CMReconnect CMMessageIdE = 104
CMMessageIdE__CMSearchFriend CMMessageIdE = 105
CMMessageIdE__CMListPendingFriendRequest CMMessageIdE = 106
CMMessageIdE__CMSearchUserByAccountId CMMessageIdE = 105
CMMessageIdE__CMSearchUser CMMessageIdE = 106
CMMessageIdE__CMAddFriendRequest CMMessageIdE = 107
CMMessageIdE__CMAcceptFriendRequest CMMessageIdE = 108
CMMessageIdE__CMListFriend CMMessageIdE = 109
CMMessageIdE__CMRejectFriendRequest CMMessageIdE = 109
CMMessageIdE__CMListPendingFriendRequest CMMessageIdE = 110
CMMessageIdE__CMListFriend CMMessageIdE = 111
CMMessageIdE__CMDeleteFriendShip CMMessageIdE = 112
)
// Enum value maps for CMMessageIdE.
@ -40,21 +43,27 @@ var (
101: "_CMPing",
103: "_CMLogin",
104: "_CMReconnect",
105: "_CMSearchFriend",
106: "_CMListPendingFriendRequest",
105: "_CMSearchUserByAccountId",
106: "_CMSearchUser",
107: "_CMAddFriendRequest",
108: "_CMAcceptFriendRequest",
109: "_CMListFriend",
109: "_CMRejectFriendRequest",
110: "_CMListPendingFriendRequest",
111: "_CMListFriend",
112: "_CMDeleteFriendShip",
}
CMMessageIdE_value = map[string]int32{
"_CMPing": 101,
"_CMLogin": 103,
"_CMReconnect": 104,
"_CMSearchFriend": 105,
"_CMListPendingFriendRequest": 106,
"_CMSearchUserByAccountId": 105,
"_CMSearchUser": 106,
"_CMAddFriendRequest": 107,
"_CMAcceptFriendRequest": 108,
"_CMListFriend": 109,
"_CMRejectFriendRequest": 109,
"_CMListPendingFriendRequest": 110,
"_CMListFriend": 111,
"_CMDeleteFriendShip": 112,
}
)
@ -100,13 +109,16 @@ type SMMessageIdE int32
const (
SMMessageIdE__SMPing SMMessageIdE = 101
SMMessageIdE__SMRpcError SMMessageIdE = 102
SMMessageIdE__SMLogin SMMessageIdE = 103
SMMessageIdE__SMReconnect SMMessageIdE = 104
SMMessageIdE__SMSearchFriend SMMessageIdE = 105
SMMessageIdE__SMListPendingFriendRequest SMMessageIdE = 106
SMMessageIdE__SMSearchUserByAccountId SMMessageIdE = 105
SMMessageIdE__SMSearchUser SMMessageIdE = 106
SMMessageIdE__SMAddFriendRequest SMMessageIdE = 107
SMMessageIdE__SMAcceptFriendRequest SMMessageIdE = 108
SMMessageIdE__SMListFriend SMMessageIdE = 109
SMMessageIdE__SMLogin SMMessageIdE = 103
SMMessageIdE__SMRejectFriendRequest SMMessageIdE = 109
SMMessageIdE__SMListPendingFriendRequest SMMessageIdE = 110
SMMessageIdE__SMListFriend SMMessageIdE = 111
SMMessageIdE__SMDeleteFriendShip SMMessageIdE = 112
)
// Enum value maps for SMMessageIdE.
@ -114,24 +126,30 @@ var (
SMMessageIdE_name = map[int32]string{
101: "_SMPing",
102: "_SMRpcError",
103: "_SMLogin",
104: "_SMReconnect",
105: "_SMSearchFriend",
106: "_SMListPendingFriendRequest",
105: "_SMSearchUserByAccountId",
106: "_SMSearchUser",
107: "_SMAddFriendRequest",
108: "_SMAcceptFriendRequest",
109: "_SMListFriend",
103: "_SMLogin",
109: "_SMRejectFriendRequest",
110: "_SMListPendingFriendRequest",
111: "_SMListFriend",
112: "_SMDeleteFriendShip",
}
SMMessageIdE_value = map[string]int32{
"_SMPing": 101,
"_SMRpcError": 102,
"_SMLogin": 103,
"_SMReconnect": 104,
"_SMSearchFriend": 105,
"_SMListPendingFriendRequest": 106,
"_SMSearchUserByAccountId": 105,
"_SMSearchUser": 106,
"_SMAddFriendRequest": 107,
"_SMAcceptFriendRequest": 108,
"_SMListFriend": 109,
"_SMLogin": 103,
"_SMRejectFriendRequest": 109,
"_SMListPendingFriendRequest": 110,
"_SMListFriend": 111,
"_SMDeleteFriendShip": 112,
}
)
@ -176,32 +194,42 @@ var File_cs_msgid_proto protoreflect.FileDescriptor
var file_cs_msgid_proto_rawDesc = []byte{
0x0a, 0x0e, 0x63, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x02, 0x63, 0x73, 0x2a, 0xba, 0x01, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x12, 0x02, 0x63, 0x73, 0x2a, 0x8b, 0x02, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x43, 0x4d, 0x50, 0x69, 0x6e,
0x67, 0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x43, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10,
0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x10, 0x68, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x69, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x43, 0x4d, 0x4c,
0x69, 0x73, 0x74, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x43, 0x4d,
0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x43, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46,
0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x11,
0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10,
0x6d, 0x2a, 0xcb, 0x01, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49,
0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65,
0x12, 0x0f, 0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10,
0x66, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x10, 0x68, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x69, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x4c,
0x69, 0x73, 0x74, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d,
0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46,
0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x11,
0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10,
0x6d, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67, 0x42,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
0x74, 0x10, 0x68, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x10,
0x69, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73,
0x65, 0x72, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x43, 0x4d, 0x41, 0x64, 0x64, 0x46, 0x72,
0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6b, 0x12, 0x1a, 0x0a,
0x16, 0x5f, 0x43, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x43, 0x4d,
0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x10, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x43, 0x4d, 0x4c, 0x69, 0x73, 0x74,
0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x69, 0x73,
0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x43, 0x4d,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70,
0x10, 0x70, 0x2a, 0x9c, 0x02, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10,
0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72,
0x10, 0x66, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67,
0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
0x10, 0x68, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55,
0x73, 0x65, 0x72, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x10, 0x69,
0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65,
0x72, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x46, 0x72, 0x69,
0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16,
0x5f, 0x53, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x52,
0x65, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x10, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x50,
0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74,
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70, 0x10,
0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
}
var (

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,6 @@
package main
import (
"math/rand"
"strings"
)
import "q5"
// User 用户实体
type User struct {
@ -23,27 +20,13 @@ type FriendRequest struct {
ReceiverID int
}
// BlockedUser 直接存列表, 黑名单上限就50个
type BlockedUser struct {
AccountId string
BlockedAccountId string
}
// RandomString generates a random string of length n
const alphabet = "abcdefghijklmnopqrstuvwxyz"
func RandomString(n int) string {
var sb strings.Builder
k := len(alphabet)
for i := 0; i < n; i++ {
c := alphabet[rand.Intn(k)]
sb.WriteByte(c)
}
return sb.String()
}
// RandomUsername generates a random username
func RandomUsername() string {
return RandomString(6)
return q5.RandomString(6)
}

View File

@ -13,16 +13,16 @@ import (
const (
FriendMemberCount = 200
PendingReqsCount = 20
PendingReqCount = 20
)
type FriendsMgr struct {
cs.MsgHandlerImpl
users map[string]*User
searchCaches map[string]SearchCache
friendships map[string][]*Friendship
pendingReqs map[string]map[string]bool
blockedUser map[string][]string
users map[string]*User // AccountId -> 用户
searchCaches map[string]SearchCache // SearchKeyword -> 好友搜索结果 []*User
friendships map[string][]*Friendship // AccountId -> 好友关系列表 []*Friendship
pendingReqs map[string]map[string]bool // AccountId -> 等待请求列表 map[account2Id]true
blockedUser map[string][]string // AccountId -> 黑名单列表 []AccountIds
}
type SearchCache struct {
@ -75,7 +75,7 @@ func (fm *FriendsMgr) unInit() {
// 2. Struct Data Persist to DB
}
func (fm *FriendsMgr) searchUserByAccountId(accountId string) *User {
func (fm *FriendsMgr) searchByAccountId(accountId string) *User {
if user, ok := fm.users[accountId]; ok {
return user
}
@ -93,7 +93,8 @@ func (fm *FriendsMgr) searchUsers(keyword string) []*User {
}
}
var listFriend []*User
maxUsers := 20
listFriend := make([]*User, 0, maxUsers)
lowercaseQuery := strings.ToLower(keyword)
for _, u := range fm.users {
if strings.Contains(strings.ToLower(u.Username), lowercaseQuery) {
@ -103,6 +104,10 @@ func (fm *FriendsMgr) searchUsers(keyword string) []*User {
}
listFriend = append(listFriend, uEntity)
}
// 显示搜索结果 20条
if len(listFriend) >= maxUsers {
break
}
}
// Add to caches
@ -112,6 +117,9 @@ func (fm *FriendsMgr) searchUsers(keyword string) []*User {
}
fm.clearExpiredCaches()
// Print result:
PrintUsers("Search result:", listFriend)
return listFriend
}
@ -119,15 +127,37 @@ func (fm *FriendsMgr) addBlocked(account1Id string, account2Id string) error {
if fm.blockedUser[account1Id] == nil {
fm.blockedUser[account1Id] = []string{}
}
fm.blockedUser[account1Id] = append(fm.blockedUser[account1Id], account2Id)
if len(fm.blockedUser[account1Id]) >= 50 {
return fmt.Errorf("your blacklist has reached the limit")
}
index := fm.findBlockedUserIndex(account1Id, account2Id)
if index < 0 {
fm.blockedUser[account1Id] = append(fm.blockedUser[account1Id], account2Id)
}
return nil
}
func (fm *FriendsMgr) removeBlocked(account1Id string, account2Id string) error {
if fm.blockedUser[account1Id] == nil {
return fmt.Errorf("your blacklist is emtpy")
}
index := fm.findBlockedUserIndex(account1Id, account2Id)
if index < 0 {
return fmt.Errorf("your blacklist not exists target account id")
}
blockedUsers := fm.blockedUser[account1Id]
blockedUsers = append(blockedUsers[:index], blockedUsers[index+1:]...)
fm.blockedUser[account1Id] = blockedUsers
return nil
}
// addFriendRequest 发送好友请求
// addFriendRequest 添加好友请求
func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) error {
_, exists1 := fm.users[account1Id]
_, exists2 := fm.users[account2Id]
@ -146,22 +176,28 @@ func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) err
return errors.New("users in blocked")
}
}
// step2. check target user member count
// 已发送请求
if _, ok := fm.pendingReqs[account1Id][account2Id]; ok {
return nil
}
// 自己好友已满
if fm.getFriendCount(account1Id) >= FriendMemberCount {
return fmt.Errorf("player:%s, friends are full", account1Id)
}
// 对方好友已满
if fm.getFriendCount(account2Id) >= FriendMemberCount {
return fmt.Errorf("player:%s, friends are full", account2Id)
}
// step3. check target user pending request count
if fm.getFriendRequestCount(account2Id) >= PendingReqsCount {
// 对方待请求已满
if fm.getFriendRequestCount(account2Id) >= PendingReqCount {
return fmt.Errorf("player:%s, friends are full", account2Id)
}
// 为 account2Id 创建等待验证好友请求 记录,由 account1Id 申请的
if fm.pendingReqs[account2Id] == nil {
fm.pendingReqs[account2Id] = make(map[string]bool)
fm.pendingReqs[account2Id] = make(map[string]bool, 0)
}
fm.pendingReqs[account1Id][account2Id] = true
fm.pendingReqs[account2Id][account1Id] = true
return nil
@ -169,12 +205,9 @@ func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) err
// acceptFriendRequest 接受好友请求
func (fm *FriendsMgr) acceptFriendRequest(account1Id string, account2Id string) error {
if !fm.pendingReqs[account1Id][account2Id] {
if _, ok := fm.pendingReqs[account1Id][account2Id]; ok {
return errors.New("no pending friend request from account1Id to account2Id")
}
// step1. delete or update friend request record
// step2. add friend history to db
// step3. add friendship
if fm.getFriendCount(account1Id) >= FriendMemberCount {
return fmt.Errorf("player:%s, friends are full", account1Id)
@ -206,28 +239,42 @@ func (fm *FriendsMgr) rejectFriendRequest(account1Id string, account2Id string)
if fm.pendingReqs[account1Id] == nil {
return errors.New("no pending friend request to reject")
}
if !fm.pendingReqs[account1Id][account2Id] {
if _, ok := fm.pendingReqs[account1Id][account2Id]; ok {
return errors.New("no pending friend request from user1 to user2")
}
delete(fm.pendingReqs[account1Id], account2Id)
if len(fm.pendingReqs[account2Id]) == 0 {
delete(fm.pendingReqs, account2Id)
}
//err := fm.acceptFriendRequestToDB(account1Id, account2Id)
//if err != nil {
// return err
//}
//fm.pendingReqs[account1Id], account2Id
//fm.pendingReqs[account2Id], account1Id
delete(fm.pendingReqs[account2Id], account1Id)
return nil
}
func (fm *FriendsMgr) deleteFriendShip(accountId string, account2Id string) {
//delete(fm.friendships[accountId], account2Id)
// deleteFriendShip 删除好友
func (fm *FriendsMgr) deleteFriendShip(account1ID, account2ID string) error {
user1Friendships := fm.friendships[account1ID]
user2Friendships := fm.friendships[account2ID]
var found bool
for i, friendship := range user1Friendships {
if friendship.User1.Username == account2ID || friendship.User2.Username == account2ID {
fm.friendships[account1ID] = append(user1Friendships[:i], user1Friendships[i+1:]...)
found = true
break
}
}
if !found {
return errors.New("friendship not found")
}
for i, friendship := range user2Friendships {
if friendship.User1.Username == account1ID || friendship.User2.Username == account1ID {
fm.friendships[account2ID] = append(user2Friendships[:i], user2Friendships[i+1:]...)
break
}
}
return nil
}
// getFriendCount 好友数量
@ -348,15 +395,15 @@ func (fm *FriendsMgr) loadPendingRequestsFromDB(conn *q5.Mysql) {
if err := rows.Scan(&senderAccountId, &receiverAccountId, &requestStatus); err != nil {
continue
}
if pendingReqs[senderAccountId] == nil {
pendingReqs[senderAccountId] = make(map[string]bool)
if pendingReqs[receiverAccountId] == nil {
pendingReqs[receiverAccountId] = make(map[string]bool)
}
status := true
if requestStatus == "1" {
// 等待验证的好友请求, 拒绝
status = false
}
pendingReqs[senderAccountId][receiverAccountId] = status
pendingReqs[receiverAccountId][senderAccountId] = status
}
if err := rows.Err(); err != nil {
return
@ -394,3 +441,28 @@ func PrintUsers(str string, userList []*User) {
fmt.Printf("[%s]:accountId:%s, username:%s \n", str, user.AccountId, user.Username)
}
}
func (fm *FriendsMgr) findBlockedUserIndex(Account1Id, Account2Id string) int {
if fm.blockedUser[Account1Id] != nil {
for i, blockedAccountId := range fm.blockedUser[Account1Id] {
if blockedAccountId == Account2Id {
return i
}
}
}
return -1
}
func (fm *FriendsMgr) findFriendShipIndex(Account1Id, Account2Id string) int {
// 通常 account1Id,指自己, account2Id 指对方
if _, exists := fm.friendships[Account1Id]; exists {
for i, friendship := range fm.friendships[Account1Id] {
if friendship.User2.AccountId == Account2Id {
return i
}
}
}
return -1
}

View File

@ -1,6 +1,5 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=

View File

@ -239,33 +239,6 @@ func (gm *GuildMgr) WriteLog(guildID int, accountId string, logType uint16, cont
gm.Logs[guildID] = append(gm.Logs[guildID], log)
}
// SearchGuilds 根据关键字搜索公会
func (gm *GuildMgr) SearchGuilds(keyword string) []Guild {
var results []Guild
for _, guild := range gm.Guilds {
if containsSubstring(guild.Name, keyword) {
results = append(results, *guild)
}
}
return results
}
// RandomGuilds 随机显示10个公会
func (gm *GuildMgr) RandomGuilds() []Guild {
randomGuildNum := 10
count := len(gm.Guilds)
if count <= randomGuildNum {
randomGuildNum = count
}
// shuffle 从count50返回一个slice []int, 包含10个元素
randIndices := rand.Perm(count)[:randomGuildNum]
var results []Guild
for _, idx := range randIndices {
results = append(results, *gm.Guilds[idx])
}
return results
}
// Disband 解散公会
func (gm *GuildMgr) Disband(guildID int, accountId string) error {
guild, exists := gm.Guilds[guildID]
@ -283,6 +256,8 @@ func (gm *GuildMgr) Disband(guildID int, accountId string) error {
gm.Guilds[guildID] = nil
gm.PendingAccountIds[guildID] = nil
gm.Logs[guildID] = nil
// 确保在删除之前没有其他地方引用了公会对象的指针, 以避免空指针异常
delete(gm.Guilds, guildID)
delete(gm.PendingAccountIds, guildID)
delete(gm.Logs, guildID)
@ -292,6 +267,59 @@ func (gm *GuildMgr) Disband(guildID int, accountId string) error {
return nil
}
// SearchGuilds 根据关键字搜索公会
func (gm *GuildMgr) SearchGuilds(keyword string) []Guild {
var results []Guild
for _, guild := range gm.Guilds {
if containsSubstring(guild.Name, keyword) {
results = append(results, *guild)
}
}
return results
}
// RandomGuilds 随机10个公会
func (gm *GuildMgr) RandomGuilds() []Guild {
randomGuildNum := 10
count := len(gm.Guilds)
if count <= randomGuildNum {
randomGuildNum = count
}
// shuffle 从count50返回一个slice []int, 包含10个元素
randIndices := rand.Perm(count)[:randomGuildNum]
var results []Guild
for _, idx := range randIndices {
results = append(results, *gm.Guilds[idx])
}
return results
}
// GetGuildByAccountId 查询我的工会
func (gm *GuildMgr) GetGuildByAccountId(accountId string) *Guild {
for _, guild := range gm.Guilds {
for _, member := range guild.Members {
if accountId == member.AccountId {
return guild
}
}
}
return nil
}
// Info 工会信息
func (gm *GuildMgr) Info(accountId string) (*Guild, []string, []*GuildLog) {
guild := gm.GetGuildByAccountId(accountId)
pendingAccountIds := make([]string, 10)
guildLogs := make([]*GuildLog, 10)
if guild != nil {
guildId := guild.ID
pendingAccountIds = gm.PendingAccountIds[guildId]
guildLogs = gm.Logs[guildId]
}
return guild, pendingAccountIds, guildLogs
}
func containsSubstring(s, substr string) bool {
return len(s) >= len(substr) && s[len(s)-len(substr):] == substr
}

View File

@ -14,7 +14,14 @@ func (this *HandlerMgr) init() {
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchFriend), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUser), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUserByAccountId), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddFriendRequest), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMAcceptFriendRequest), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMRejectFriendRequest), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMListPendingFriendRequest), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMListFriend), PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMDeleteFriendShip), PLAYER_HANDLER_ID)
}
func (this *HandlerMgr) unInit() {

View File

@ -3,6 +3,7 @@ package main
import (
"cs"
"f5"
"fmt"
)
type Player struct {
@ -12,35 +13,36 @@ type Player struct {
sessionId string
}
func (p *Player) CMSearchFriends(hdr *f5.MsgHdr, msg *cs.CMSearchFriend) {
rspMsg := new(cs.SMSearchFriend)
// CMSearchUser 搜索用户
func (p *Player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
rspMsg := new(cs.SMSearchUser)
//rspMsg := &cs.SMSearchFriend{}
listUsers := friendMgr.searchUsers(msg.GetSearchKeyword())
for _, u := range listUsers {
friend := &cs.MFFriend{
friend := &cs.MFUser{
AccountId: &u.AccountId,
Username: &u.Username,
}
rspMsg.Friends = append(rspMsg.Friends, friend)
rspMsg.Users = append(rspMsg.Users, friend)
}
fmt.Printf("length%d \n", len(rspMsg.Users))
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMSearchUserByAccountId 搜索指定用户
func (p *Player) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *cs.CMSearchUserByAccountId) {
rspMsg := new(cs.SMSearchUserByAccountId)
user := friendMgr.searchByAccountId(msg.GetSearchKeyword())
if user != nil {
rspMsg.AccountId = &user.AccountId
rspMsg.Username = &user.Username
fmt.Printf("search result: accountId:%s \n", *rspMsg.AccountId)
}
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMListPendingFriendRequest 等待验证的好友请求
func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {
rspMsg := &cs.SMListPendingFriendRequest{}
accountId := p.accountId
for accountId, flag := range friendMgr.pendingReqs[accountId] {
row := &cs.MFPendingFriendRequest{
AccountId: &accountId,
Flag: &flag,
}
rspMsg.PendingFriendRequest = append(rspMsg.PendingFriendRequest, row)
}
f5.GetSysLog().Info("CMListPendingFriendRequest requests count:%d\n", len(rspMsg.PendingFriendRequest))
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMAddFriendRequest 添加好友请求
func (p *Player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendRequest) {
rspMsg := &cs.SMAddFriendRequest{}
@ -60,6 +62,7 @@ func (p *Player) CMAddFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAddFriendRequest)
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMAcceptFriendRequest 接受好友请求
func (p *Player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriendRequest) {
rspMsg := &cs.SMAcceptFriendRequest{}
@ -79,25 +82,80 @@ func (p *Player) CMAcceptFriendRequest(hdr *f5.MsgHdr, msg *cs.CMAcceptFriendReq
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMRejectFriendRequest 拒绝好友请求
func (p *Player) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *cs.CMRejectFriendRequest) {
rspMsg := &cs.SMRejectFriendRequest{}
user1Id := p.accountId
user2Id := msg.GetTargetAccountId()
err := friendMgr.acceptFriendRequest(user1Id, user2Id)
if err != nil {
reason := err.Error()
rspMsg.Reason = &reason
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
f5.GetSysLog().Info("CMAcceptFriendRequest: reason:%s, params: %s or %s\n", reason, user1Id, user2Id)
return
}
status := "reject"
rspMsg.Status = &status
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMListPendingFriendRequest 等待验证的好友请求
func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {
rspMsg := &cs.SMListPendingFriendRequest{}
accountId := p.accountId
for accountId, flag := range friendMgr.pendingReqs[accountId] {
row := &cs.MFPendingFriendRequest{
AccountId: &accountId,
Flag: &flag,
}
rspMsg.PendingFriendRequest = append(rspMsg.PendingFriendRequest, row)
}
f5.GetSysLog().Info("CMListPendingFriendRequest requests count:%d\n", len(rspMsg.PendingFriendRequest))
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMListFriend 我的好友列表
func (p *Player) CMListFriend(hdr *f5.MsgHdr, msg *cs.CMListFriend) {
rspMsg := &cs.SMListFriend{}
accountId := p.accountId
for _, friendship := range friendMgr.friendships[accountId] {
if friendship.User1.AccountId != accountId {
friend := &cs.MFFriend{
friend := &cs.MFUser{
AccountId: &friendship.User1.AccountId,
Username: &friendship.User1.Username,
}
rspMsg.Friends = append(rspMsg.Friends, friend)
rspMsg.Users = append(rspMsg.Users, friend)
} else {
friend := &cs.MFFriend{
friend := &cs.MFUser{
AccountId: &friendship.User2.AccountId,
Username: &friendship.User2.Username,
}
rspMsg.Friends = append(rspMsg.Friends, friend)
rspMsg.Users = append(rspMsg.Users, friend)
}
}
f5.GetSysLog().Info("CMListFriend friends count:%d\n", len(rspMsg.Friends))
f5.GetSysLog().Info("CMListFriend friends count:%d\n", len(rspMsg.Users))
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMDeleteFriendShip 删除好友
func (p *Player) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *cs.CMDeleteFriendShip) {
rspMsg := &cs.SMDeleteFriendShip{}
user1Id := p.accountId
user2Id := msg.GetTargetAccountId()
err := friendMgr.deleteFriendShip(user1Id, user2Id)
if err != nil {
reason := err.Error()
rspMsg.Reason = &reason
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
f5.GetSysLog().Info("CMDeleteFriendShip: reason:%s, params: %s or %s\n", reason, user1Id, user2Id)
return
}
status := "deleted"
rspMsg.Status = &status
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}

View File

@ -6,25 +6,33 @@ option go_package = ".;cs";
enum CMMessageId_e
{
_CMPing = 101;
_CMLogin = 103;
_CMReconnect = 104;
_CMSearchFriend = 105;
_CMListPendingFriendRequest = 106;
_CMSearchUserByAccountId = 105;
_CMSearchUser = 106;
_CMAddFriendRequest = 107;
_CMAcceptFriendRequest = 108;
_CMListFriend = 109;
_CMRejectFriendRequest = 109;
_CMListPendingFriendRequest = 110;
_CMListFriend = 111;
_CMDeleteFriendShip = 112;
}
enum SMMessageId_e
{
_SMPing = 101;
_SMRpcError = 102;
_SMLogin = 103;
_SMReconnect = 104;
_SMSearchFriend = 105;
_SMListPendingFriendRequest = 106;
_SMSearchUserByAccountId = 105;
_SMSearchUser = 106;
_SMAddFriendRequest = 107;
_SMAcceptFriendRequest = 108;
_SMListFriend = 109;
_SMLogin = 103;
_SMRejectFriendRequest = 109;
_SMListPendingFriendRequest = 110;
_SMListFriend = 111;
_SMDeleteFriendShip = 112;
}

View File

@ -119,38 +119,34 @@ message SMReconnect
//
message CMSearchFriend
message CMSearchUser
{
optional int32 server_id = 1; //
optional string team_uuid = 2; //
optional string search_keyword = 6; //
optional string search_keyword = 1; //
}
//
message SMSearchFriend
message SMSearchUser
{
repeated MFFriend friends = 1;
repeated MFUser users = 1;
}
//
message CMListPendingFriendRequest
// CMSearchUserByAccountId
message CMSearchUserByAccountId
{
optional int32 server_id = 1; //
optional string team_uuid = 2; //
optional string search_keyword = 1; //account id
}
//
message SMListPendingFriendRequest
//
message SMSearchUserByAccountId
{
repeated MFPendingFriendRequest pendingFriendRequest = 1;
optional string account_id = 1;
optional string username = 2;
}
//
message CMAddFriendRequest
{
optional int32 server_id = 1; //
optional string team_uuid = 2; //
optional string target_account_id = 3; //id
optional string target_account_id = 1; // id
}
//
@ -160,41 +156,74 @@ message SMAddFriendRequest
optional string status = 2;
}
//
//
message CMAcceptFriendRequest
{
optional int32 server_id = 1; //
optional string team_uuid = 2; //
optional string target_account_id = 3; //
optional string target_account_id = 1; // id
}
//
//
message SMAcceptFriendRequest
{
optional string reason = 1;
optional string status = 2;
}
//
message CMListFriend
//
message CMRejectFriendRequest
{
optional string target_account_id = 1; // id
}
//
message SMRejectFriendRequest
{
optional string reason = 1;
optional string status = 2;
}
//
message CMListPendingFriendRequest
{
optional int32 server_id = 1; //
optional string team_uuid = 2; //
}
//
message SMListPendingFriendRequest
{
repeated MFPendingFriendRequest pendingFriendRequest = 1;
}
//
message CMListFriend
{
}
//
message SMListFriend
{
repeated MFUser users = 1;
}
//
message CMDeleteFriendShip
{
optional string target_account_id = 1; // id
}
//
message SMDeleteFriendShip
{
optional string reason = 1;
optional string status = 2;
}
message MFUser {
optional string account_id = 1;
optional string username = 2;
}
message MFPendingFriendRequest {
optional string account_id = 1;
optional bool flag = 2;
}
//
message MFFriend {
optional string account_id = 1;
optional string username = 2;
}
message SMListFriend
{
repeated MFFriend friends = 1;
}

View File

@ -38,8 +38,6 @@ type MsgHandler interface {
SS_Ping(*f5.MsgHdr, *SS_Ping)
SS_Pong(*f5.MsgHdr, *SS_Pong)
SS_WSP_SocketDisconnect(*f5.MsgHdr, *SS_WSP_SocketDisconnect)
SS_WSP_RequestTargetServer(*f5.MsgHdr, *SS_WSP_RequestTargetServer)
SS_MS_ResponseTargetServer(*f5.MsgHdr, *SS_MS_ResponseTargetServer)
SS_ForceCloseSocket(*f5.MsgHdr, *SS_ForceCloseSocket)
}
@ -52,12 +50,6 @@ func (this *MsgHandlerImpl) SS_Pong(hdr *f5.MsgHdr, msg *SS_Pong) {
func (this *MsgHandlerImpl) SS_WSP_SocketDisconnect(hdr *f5.MsgHdr, msg *SS_WSP_SocketDisconnect) {
}
func (this *MsgHandlerImpl) SS_WSP_RequestTargetServer(hdr *f5.MsgHdr, msg *SS_WSP_RequestTargetServer) {
}
func (this *MsgHandlerImpl) SS_MS_ResponseTargetServer(hdr *f5.MsgHdr, msg *SS_MS_ResponseTargetServer) {
}
func (this *MsgHandlerImpl) SS_ForceCloseSocket(hdr *f5.MsgHdr, msg *SS_ForceCloseSocket) {
}
@ -73,14 +65,6 @@ func (this *SS_WSP_SocketDisconnect) GetNetMsgId() uint16 {
return uint16(SSMessageIdE__SS_WSP_SocketDisconnect)
}
func (this *SS_WSP_RequestTargetServer) GetNetMsgId() uint16 {
return uint16(SSMessageIdE__SS_WSP_RequestTargetServer)
}
func (this *SS_MS_ResponseTargetServer) GetNetMsgId() uint16 {
return uint16(SSMessageIdE__SS_MS_ResponseTargetServer)
}
func (this *SS_ForceCloseSocket) GetNetMsgId() uint16 {
return uint16(SSMessageIdE__SS_ForceCloseSocket)
}
@ -123,30 +107,6 @@ func init() {
},
}
handlers[int(SSMessageIdE__SS_WSP_RequestTargetServer)] = &SsNetMsgHandler{
MsgId: int(SSMessageIdE__SS_WSP_RequestTargetServer),
ParseCb: func (data []byte) interface{} {
msg := &SS_WSP_RequestTargetServer{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.SS_WSP_RequestTargetServer(hdr, hdr.Msg.(*SS_WSP_RequestTargetServer))
},
}
handlers[int(SSMessageIdE__SS_MS_ResponseTargetServer)] = &SsNetMsgHandler{
MsgId: int(SSMessageIdE__SS_MS_ResponseTargetServer),
ParseCb: func (data []byte) interface{} {
msg := &SS_MS_ResponseTargetServer{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.SS_MS_ResponseTargetServer(hdr, hdr.Msg.(*SS_MS_ResponseTargetServer))
},
}
handlers[int(SSMessageIdE__SS_ForceCloseSocket)] = &SsNetMsgHandler{
MsgId: int(SSMessageIdE__SS_ForceCloseSocket),
ParseCb: func (data []byte) interface{} {

View File

@ -24,12 +24,10 @@ const (
type SSMessageIdE int32
const (
SSMessageIdE__SS_Ping SSMessageIdE = 8
SSMessageIdE__SS_Pong SSMessageIdE = 9
SSMessageIdE__SS_WSP_SocketDisconnect SSMessageIdE = 10
SSMessageIdE__SS_WSP_RequestTargetServer SSMessageIdE = 11
SSMessageIdE__SS_MS_ResponseTargetServer SSMessageIdE = 12
SSMessageIdE__SS_ForceCloseSocket SSMessageIdE = 13
SSMessageIdE__SS_Ping SSMessageIdE = 8
SSMessageIdE__SS_Pong SSMessageIdE = 9
SSMessageIdE__SS_WSP_SocketDisconnect SSMessageIdE = 10
SSMessageIdE__SS_ForceCloseSocket SSMessageIdE = 13
)
// Enum value maps for SSMessageIdE.
@ -38,17 +36,13 @@ var (
8: "_SS_Ping",
9: "_SS_Pong",
10: "_SS_WSP_SocketDisconnect",
11: "_SS_WSP_RequestTargetServer",
12: "_SS_MS_ResponseTargetServer",
13: "_SS_ForceCloseSocket",
}
SSMessageIdE_value = map[string]int32{
"_SS_Ping": 8,
"_SS_Pong": 9,
"_SS_WSP_SocketDisconnect": 10,
"_SS_WSP_RequestTargetServer": 11,
"_SS_MS_ResponseTargetServer": 12,
"_SS_ForceCloseSocket": 13,
"_SS_Ping": 8,
"_SS_Pong": 9,
"_SS_WSP_SocketDisconnect": 10,
"_SS_ForceCloseSocket": 13,
}
)
@ -93,18 +87,14 @@ var File_ss_msgid_proto protoreflect.FileDescriptor
var file_ss_msgid_proto_rawDesc = []byte{
0x0a, 0x0e, 0x73, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x02, 0x73, 0x73, 0x2a, 0xa5, 0x01, 0x0a, 0x0d, 0x53, 0x53, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x53, 0x5f, 0x50, 0x69,
0x6e, 0x67, 0x10, 0x08, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x53, 0x5f, 0x50, 0x6f, 0x6e, 0x67,
0x10, 0x09, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x53, 0x5f, 0x57, 0x53, 0x50, 0x5f, 0x53, 0x6f,
0x63, 0x6b, 0x65, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x0a,
0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x53, 0x5f, 0x57, 0x53, 0x50, 0x5f, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x10,
0x0b, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x53, 0x5f, 0x4d, 0x53, 0x5f, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x10, 0x0c, 0x12, 0x18, 0x0a, 0x14, 0x5f, 0x53, 0x53, 0x5f, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x43,
0x6c, 0x6f, 0x73, 0x65, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x0d, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x73, 0x73,
0x12, 0x02, 0x73, 0x73, 0x2a, 0x63, 0x0a, 0x0d, 0x53, 0x53, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x53, 0x5f, 0x50, 0x69, 0x6e,
0x67, 0x10, 0x08, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x53, 0x5f, 0x50, 0x6f, 0x6e, 0x67, 0x10,
0x09, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x53, 0x5f, 0x57, 0x53, 0x50, 0x5f, 0x53, 0x6f, 0x63,
0x6b, 0x65, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x0a, 0x12,
0x18, 0x0a, 0x14, 0x5f, 0x53, 0x53, 0x5f, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x43, 0x6c, 0x6f, 0x73,
0x65, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x0d, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x73,
0x73,
}
var (

View File

@ -134,148 +134,6 @@ func (*SS_WSP_SocketDisconnect) Descriptor() ([]byte, []int) {
return file_ss_proto_proto_rawDescGZIP(), []int{2}
}
type SS_WSP_RequestTargetServer struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ContextId *int64 `protobuf:"varint,1,opt,name=context_id,json=contextId" json:"context_id,omitempty"`
AccountId *string `protobuf:"bytes,2,opt,name=account_id,json=accountId" json:"account_id,omitempty"`
TeamId *string `protobuf:"bytes,3,opt,name=team_id,json=teamId" json:"team_id,omitempty"`
}
func (x *SS_WSP_RequestTargetServer) Reset() {
*x = SS_WSP_RequestTargetServer{}
if protoimpl.UnsafeEnabled {
mi := &file_ss_proto_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SS_WSP_RequestTargetServer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SS_WSP_RequestTargetServer) ProtoMessage() {}
func (x *SS_WSP_RequestTargetServer) ProtoReflect() protoreflect.Message {
mi := &file_ss_proto_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SS_WSP_RequestTargetServer.ProtoReflect.Descriptor instead.
func (*SS_WSP_RequestTargetServer) Descriptor() ([]byte, []int) {
return file_ss_proto_proto_rawDescGZIP(), []int{3}
}
func (x *SS_WSP_RequestTargetServer) GetContextId() int64 {
if x != nil && x.ContextId != nil {
return *x.ContextId
}
return 0
}
func (x *SS_WSP_RequestTargetServer) GetAccountId() string {
if x != nil && x.AccountId != nil {
return *x.AccountId
}
return ""
}
func (x *SS_WSP_RequestTargetServer) GetTeamId() string {
if x != nil && x.TeamId != nil {
return *x.TeamId
}
return ""
}
type SS_MS_ResponseTargetServer struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ErrorCode *int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode" json:"error_code,omitempty"`
ErrorMsg *string `protobuf:"bytes,2,opt,name=error_msg,json=errorMsg" json:"error_msg,omitempty"`
ContextId *int64 `protobuf:"varint,3,opt,name=context_id,json=contextId" json:"context_id,omitempty"`
Host *string `protobuf:"bytes,4,opt,name=host" json:"host,omitempty"`
Port *int32 `protobuf:"varint,5,opt,name=port" json:"port,omitempty"`
}
func (x *SS_MS_ResponseTargetServer) Reset() {
*x = SS_MS_ResponseTargetServer{}
if protoimpl.UnsafeEnabled {
mi := &file_ss_proto_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SS_MS_ResponseTargetServer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SS_MS_ResponseTargetServer) ProtoMessage() {}
func (x *SS_MS_ResponseTargetServer) ProtoReflect() protoreflect.Message {
mi := &file_ss_proto_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SS_MS_ResponseTargetServer.ProtoReflect.Descriptor instead.
func (*SS_MS_ResponseTargetServer) Descriptor() ([]byte, []int) {
return file_ss_proto_proto_rawDescGZIP(), []int{4}
}
func (x *SS_MS_ResponseTargetServer) GetErrorCode() int32 {
if x != nil && x.ErrorCode != nil {
return *x.ErrorCode
}
return 0
}
func (x *SS_MS_ResponseTargetServer) GetErrorMsg() string {
if x != nil && x.ErrorMsg != nil {
return *x.ErrorMsg
}
return ""
}
func (x *SS_MS_ResponseTargetServer) GetContextId() int64 {
if x != nil && x.ContextId != nil {
return *x.ContextId
}
return 0
}
func (x *SS_MS_ResponseTargetServer) GetHost() string {
if x != nil && x.Host != nil {
return *x.Host
}
return ""
}
func (x *SS_MS_ResponseTargetServer) GetPort() int32 {
if x != nil && x.Port != nil {
return *x.Port
}
return 0
}
type SS_ForceCloseSocket struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -285,7 +143,7 @@ type SS_ForceCloseSocket struct {
func (x *SS_ForceCloseSocket) Reset() {
*x = SS_ForceCloseSocket{}
if protoimpl.UnsafeEnabled {
mi := &file_ss_proto_proto_msgTypes[5]
mi := &file_ss_proto_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -298,7 +156,7 @@ func (x *SS_ForceCloseSocket) String() string {
func (*SS_ForceCloseSocket) ProtoMessage() {}
func (x *SS_ForceCloseSocket) ProtoReflect() protoreflect.Message {
mi := &file_ss_proto_proto_msgTypes[5]
mi := &file_ss_proto_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -311,7 +169,7 @@ func (x *SS_ForceCloseSocket) ProtoReflect() protoreflect.Message {
// Deprecated: Use SS_ForceCloseSocket.ProtoReflect.Descriptor instead.
func (*SS_ForceCloseSocket) Descriptor() ([]byte, []int) {
return file_ss_proto_proto_rawDescGZIP(), []int{5}
return file_ss_proto_proto_rawDescGZIP(), []int{3}
}
var File_ss_proto_proto protoreflect.FileDescriptor
@ -321,26 +179,9 @@ var file_ss_proto_proto_rawDesc = []byte{
0x12, 0x02, 0x73, 0x73, 0x22, 0x09, 0x0a, 0x07, 0x53, 0x53, 0x5f, 0x50, 0x69, 0x6e, 0x67, 0x22,
0x09, 0x0a, 0x07, 0x53, 0x53, 0x5f, 0x50, 0x6f, 0x6e, 0x67, 0x22, 0x19, 0x0a, 0x17, 0x53, 0x53,
0x5f, 0x57, 0x53, 0x50, 0x5f, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x44, 0x69, 0x73, 0x63, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x22, 0x73, 0x0a, 0x1a, 0x53, 0x53, 0x5f, 0x57, 0x53, 0x50, 0x5f,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49,
0x64, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x74, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x22, 0x9f, 0x01, 0x0a, 0x1a, 0x53,
0x53, 0x5f, 0x4d, 0x53, 0x5f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x61, 0x72,
0x67, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72,
0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f,
0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72,
0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x65,
0x78, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74,
0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x15, 0x0a, 0x13,
0x53, 0x53, 0x5f, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x53, 0x6f, 0x63,
0x6b, 0x65, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x73, 0x73,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x53, 0x5f, 0x46, 0x6f, 0x72, 0x63,
0x65, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x73, 0x73,
}
var (
@ -355,14 +196,12 @@ func file_ss_proto_proto_rawDescGZIP() []byte {
return file_ss_proto_proto_rawDescData
}
var file_ss_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_ss_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_ss_proto_proto_goTypes = []interface{}{
(*SS_Ping)(nil), // 0: ss.SS_Ping
(*SS_Pong)(nil), // 1: ss.SS_Pong
(*SS_WSP_SocketDisconnect)(nil), // 2: ss.SS_WSP_SocketDisconnect
(*SS_WSP_RequestTargetServer)(nil), // 3: ss.SS_WSP_RequestTargetServer
(*SS_MS_ResponseTargetServer)(nil), // 4: ss.SS_MS_ResponseTargetServer
(*SS_ForceCloseSocket)(nil), // 5: ss.SS_ForceCloseSocket
(*SS_Ping)(nil), // 0: ss.SS_Ping
(*SS_Pong)(nil), // 1: ss.SS_Pong
(*SS_WSP_SocketDisconnect)(nil), // 2: ss.SS_WSP_SocketDisconnect
(*SS_ForceCloseSocket)(nil), // 3: ss.SS_ForceCloseSocket
}
var file_ss_proto_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@ -415,30 +254,6 @@ func file_ss_proto_proto_init() {
}
}
file_ss_proto_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SS_WSP_RequestTargetServer); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ss_proto_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SS_MS_ResponseTargetServer); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ss_proto_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SS_ForceCloseSocket); i {
case 0:
return &v.state
@ -457,7 +272,7 @@ func file_ss_proto_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_ss_proto_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},

16
server/slgserver/go.sum Normal file
View File

@ -0,0 +1,16 @@
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=