├── bin ├── log │ └── .gitignore ├── gamedata │ └── .gitignore └── conf │ └── server.json ├── .gitignore ├── README.md └── src └── server ├── gate ├── external.go ├── router.go └── internal │ └── module.go ├── game ├── external.go └── internal │ ├── module.go │ ├── chanrpc.go │ └── handler.go ├── login ├── external.go └── internal │ ├── handler.go │ └── module.go ├── msg ├── msg.go ├── lobby.proto └── lobby.pb.go ├── base └── skeleton.go ├── gamedata └── reader.go ├── conf ├── conf.go └── json.go ├── main.go └── db └── mongodb └── mongodbmgr.go /bin/log/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /bin/gamedata/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /bin/*.exe 3 | /src/github.com 4 | /pkg 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LeafServerExample 2 | Server :LeafServer Client:CocosCreator 3 | -------------------------------------------------------------------------------- /src/server/gate/external.go: -------------------------------------------------------------------------------- 1 | package gate 2 | 3 | import ( 4 | "server/gate/internal" 5 | ) 6 | 7 | var ( 8 | Module = new(internal.Module) 9 | ) 10 | -------------------------------------------------------------------------------- /bin/conf/server.json: -------------------------------------------------------------------------------- 1 | { 2 | "LogLevel": "debug", 3 | "LogPath": "", 4 | "TCPAddr": "127.0.0.1:3563", 5 | "WSAddr": "127.0.0.1:3653", 6 | "MaxConnNum": 20000 7 | } -------------------------------------------------------------------------------- /src/server/game/external.go: -------------------------------------------------------------------------------- 1 | package game 2 | 3 | import ( 4 | "server/game/internal" 5 | ) 6 | 7 | var ( 8 | Module = new(internal.Module) 9 | ChanRPC = internal.ChanRPC 10 | ) 11 | -------------------------------------------------------------------------------- /src/server/login/external.go: -------------------------------------------------------------------------------- 1 | package login 2 | 3 | import ( 4 | "server/login/internal" 5 | ) 6 | 7 | var ( 8 | Module = new(internal.Module) 9 | ChanRPC = internal.ChanRPC 10 | ) 11 | -------------------------------------------------------------------------------- /src/server/login/internal/handler.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "reflect" 5 | ) 6 | 7 | func handleMsg(m interface{}, h interface{}) { 8 | skeleton.RegisterChanRPC(reflect.TypeOf(m), h) 9 | } 10 | 11 | func init() { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/server/gate/router.go: -------------------------------------------------------------------------------- 1 | package gate 2 | 3 | import ( 4 | "server/game" 5 | "server/msg" 6 | ) 7 | 8 | func init() { 9 | // 这里指定消息 路由到 game 模块 10 | msg.Processor.SetRouter(&msg.Test{}, game.ChanRPC) 11 | msg.Processor.SetRouter(&msg.UserLogin{}, game.ChanRPC) 12 | msg.Processor.SetRouter(&msg.UserRegister{}, game.ChanRPC) 13 | } 14 | -------------------------------------------------------------------------------- /src/server/msg/msg.go: -------------------------------------------------------------------------------- 1 | package msg 2 | 3 | import ( 4 | "github.com/name5566/leaf/network/protobuf" 5 | ) 6 | 7 | // 使用 Protobuf 消息处理器 8 | var Processor = protobuf.NewProcessor() 9 | 10 | func init() { 11 | Processor.Register(&Test{}) 12 | Processor.Register(&UserLogin{}) 13 | Processor.Register(&UserRegister{}) 14 | Processor.Register(&UserResult{}) 15 | Processor.Register(&UserST{}) 16 | } 17 | -------------------------------------------------------------------------------- /src/server/game/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/module" 5 | "server/base" 6 | ) 7 | 8 | var ( 9 | skeleton = base.NewSkeleton() 10 | ChanRPC = skeleton.ChanRPCServer 11 | ) 12 | 13 | type Module struct { 14 | *module.Skeleton 15 | } 16 | 17 | func (m *Module) OnInit() { 18 | m.Skeleton = skeleton 19 | } 20 | 21 | func (m *Module) OnDestroy() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/server/login/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/module" 5 | "server/base" 6 | ) 7 | 8 | var ( 9 | skeleton = base.NewSkeleton() 10 | ChanRPC = skeleton.ChanRPCServer 11 | ) 12 | 13 | type Module struct { 14 | *module.Skeleton 15 | } 16 | 17 | func (m *Module) OnInit() { 18 | m.Skeleton = skeleton 19 | } 20 | 21 | func (m *Module) OnDestroy() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/server/game/internal/chanrpc.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/gate" 5 | ) 6 | 7 | func init() { 8 | skeleton.RegisterChanRPC("NewAgent", rpcNewAgent) 9 | skeleton.RegisterChanRPC("CloseAgent", rpcCloseAgent) 10 | } 11 | 12 | func rpcNewAgent(args []interface{}) { 13 | a := args[0].(gate.Agent) 14 | _ = a 15 | } 16 | 17 | func rpcCloseAgent(args []interface{}) { 18 | a := args[0].(gate.Agent) 19 | _ = a 20 | } 21 | -------------------------------------------------------------------------------- /src/server/base/skeleton.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "github.com/name5566/leaf/chanrpc" 5 | "github.com/name5566/leaf/module" 6 | "server/conf" 7 | ) 8 | 9 | func NewSkeleton() *module.Skeleton { 10 | skeleton := &module.Skeleton{ 11 | GoLen: conf.GoLen, 12 | TimerDispatcherLen: conf.TimerDispatcherLen, 13 | AsynCallLen: conf.AsynCallLen, 14 | ChanRPCServer: chanrpc.NewServer(conf.ChanRPCLen), 15 | } 16 | skeleton.Init() 17 | return skeleton 18 | } 19 | -------------------------------------------------------------------------------- /src/server/gamedata/reader.go: -------------------------------------------------------------------------------- 1 | package gamedata 2 | 3 | import ( 4 | "github.com/name5566/leaf/log" 5 | "github.com/name5566/leaf/recordfile" 6 | "reflect" 7 | ) 8 | 9 | func readRf(st interface{}) *recordfile.RecordFile { 10 | rf, err := recordfile.New(st) 11 | if err != nil { 12 | log.Fatal("%v", err) 13 | } 14 | fn := reflect.TypeOf(st).Name() + ".txt" 15 | err = rf.Read("gamedata/" + fn) 16 | if err != nil { 17 | log.Fatal("%v: %v", fn, err) 18 | } 19 | 20 | return rf 21 | } 22 | -------------------------------------------------------------------------------- /src/server/conf/conf.go: -------------------------------------------------------------------------------- 1 | package conf 2 | 3 | import ( 4 | "log" 5 | "time" 6 | ) 7 | 8 | var ( 9 | // log conf 10 | LogFlag = log.LstdFlags 11 | 12 | // gate conf 13 | PendingWriteNum = 2000 14 | MaxMsgLen uint32 = 4096 15 | HTTPTimeout = 10 * time.Second 16 | LenMsgLen = 2 17 | LittleEndian = false 18 | 19 | // skeleton conf 20 | GoLen = 10000 21 | TimerDispatcherLen = 10000 22 | AsynCallLen = 10000 23 | ChanRPCLen = 10000 24 | ) 25 | -------------------------------------------------------------------------------- /src/server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/name5566/leaf" 5 | lconf "github.com/name5566/leaf/conf" 6 | "server/conf" 7 | _ "server/db/mongodb" 8 | "server/game" 9 | "server/gate" 10 | "server/login" 11 | ) 12 | 13 | func main() { 14 | lconf.LogLevel = conf.Server.LogLevel 15 | lconf.LogPath = conf.Server.LogPath 16 | lconf.LogFlag = conf.LogFlag 17 | lconf.ConsolePort = conf.Server.ConsolePort 18 | lconf.ProfilePath = conf.Server.ProfilePath 19 | 20 | leaf.Run( 21 | game.Module, 22 | gate.Module, 23 | login.Module, 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /src/server/gate/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/gate" 5 | "server/conf" 6 | "server/game" 7 | "server/msg" 8 | ) 9 | 10 | type Module struct { 11 | *gate.Gate 12 | } 13 | 14 | func (m *Module) OnInit() { 15 | m.Gate = &gate.Gate{ 16 | MaxConnNum: conf.Server.MaxConnNum, 17 | PendingWriteNum: conf.PendingWriteNum, 18 | MaxMsgLen: conf.MaxMsgLen, 19 | WSAddr: conf.Server.WSAddr, 20 | HTTPTimeout: conf.HTTPTimeout, 21 | CertFile: conf.Server.CertFile, 22 | KeyFile: conf.Server.KeyFile, 23 | TCPAddr: conf.Server.TCPAddr, 24 | LenMsgLen: conf.LenMsgLen, 25 | LittleEndian: conf.LittleEndian, 26 | Processor: msg.Processor, 27 | AgentChanRPC: game.ChanRPC, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/server/conf/json.go: -------------------------------------------------------------------------------- 1 | package conf 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "github.com/name5566/leaf/log" 7 | "io/ioutil" 8 | "os" 9 | "path/filepath" 10 | ) 11 | 12 | var Server struct { 13 | LogLevel string 14 | LogPath string 15 | WSAddr string 16 | CertFile string 17 | KeyFile string 18 | TCPAddr string 19 | MaxConnNum int 20 | ConsolePort int 21 | ProfilePath string 22 | } 23 | 24 | func init() { 25 | dir, err := filepath.Abs(filepath.Dir(os.Args[0])) 26 | if err != nil { 27 | log.Fatal("%v", err) 28 | } 29 | fmt.Println(dir) 30 | 31 | data, err := ioutil.ReadFile(dir + "/conf/server.json") 32 | if err != nil { 33 | log.Fatal("%v", err) 34 | } 35 | err = json.Unmarshal(data, &Server) 36 | if err != nil { 37 | log.Fatal("%v", err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/server/msg/lobby.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package msg; 3 | 4 | enum Result { 5 | REGISTER_SUCCESS=0; 6 | REGISTER_FAIL=1; 7 | LOGIN_SUCCESS=2; 8 | LOGIN_FAIL=3; 9 | } 10 | 11 | message Test { 12 | string Test = 2; 13 | } 14 | 15 | // 用户登陆协议 16 | message UserLogin { 17 | string LoginName = 1; // 用户名 18 | string LoginPW =2; // 密码 19 | } 20 | // 注册协议 21 | message UserRegister { 22 | string LoginName =1; // 用户名 23 | string LoginPW =2; // 密码 24 | } 25 | // 消息返回协议 26 | message UserResult { 27 | Result RetResult =1; 28 | string ErrorInfo = 2; 29 | } 30 | 31 | // 玩家有角色的情况 32 | message UserST { 33 | string UID =1; // 账号ID 34 | string ServerID =2; // 服务器ID 35 | string RoleUID =3; // 角色UID 36 | string RoleName =4; // 角色名字 37 | string RoleLev =5; // 角色等级 38 | string Coin =6; // 金币 39 | // 其他的暂时不做定义 40 | } -------------------------------------------------------------------------------- /src/server/game/internal/handler.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/golang/protobuf/proto" 5 | "github.com/name5566/leaf/gate" 6 | "github.com/name5566/leaf/log" 7 | "reflect" 8 | "server/msg" 9 | "regexp" 10 | "server/db/mongodb" 11 | "gopkg.in/mgo.v2/bson" 12 | "fmt" 13 | ) 14 | 15 | func init() { 16 | // 向当前模块(game 模块)注册 消息处理函数 17 | handler(&msg.Test{}, handleTest) 18 | handler(&msg.UserLogin{}, handleUserLogin) 19 | handler(&msg.UserRegister{}, handleUserRegister) 20 | } 21 | 22 | func handler(m interface{}, h interface{}) { 23 | skeleton.RegisterChanRPC(reflect.TypeOf(m), h) 24 | } 25 | 26 | func handleTest(args []interface{}) { 27 | // 收到的 Test 消息 28 | m := args[0].(*msg.Test) 29 | // 消息的发送者 30 | a := args[1].(gate.Agent) 31 | 32 | // 输出收到的消息的内容 33 | log.Debug("hello %v", m.GetTest()) 34 | 35 | retBuf := &msg.Test{ 36 | Test: *proto.String("client"), 37 | } 38 | // 给发送者回应一个 Test 消息 39 | a.WriteMsg(retBuf) 40 | } 41 | 42 | func handleUserRegister(args []interface{}) { 43 | m := args[0].(*msg.UserRegister) 44 | a := args[1].(gate.Agent) 45 | name :=m.GetLoginName() 46 | pwd :=m.GetLoginPW() 47 | log.Debug("receive UserRegister name=%v", m.GetLoginName()) 48 | 49 | reg := regexp.MustCompile(`/^[a-zA-Z\d]\w{2,10}[a-zA-Z\d]$/`) 50 | matched := reg.FindString(name) 51 | if(matched!=" "){ 52 | log.Debug("UserRegister name is licit", ) 53 | } 54 | err := mongodbmgr.Find("game","login",bson.M{"name":name,}) 55 | if err == nil { 56 | fmt.Println(err) 57 | log.Debug("UserRegister find in fail", ) 58 | retBuf := &msg.UserResult{ 59 | RetResult: msg.Result_REGISTER_FAIL, 60 | ErrorInfo:"账号已存在!", 61 | } 62 | a.WriteMsg(retBuf) 63 | } 64 | err =mongodbmgr.Insert("game","login",bson.M{"name":name,"password":pwd}) 65 | if err != nil { 66 | fmt.Println(err) 67 | log.Debug("UserRegister write in fail", ) 68 | retBuf := &msg.UserResult{ 69 | RetResult: msg.Result_REGISTER_FAIL, 70 | ErrorInfo:"注册失败,请稍后再试!", 71 | } 72 | a.WriteMsg(retBuf) 73 | } else{ 74 | log.Debug("UserRegister write in success", ) 75 | retBuf := &msg.UserResult{ 76 | RetResult: msg.Result_REGISTER_SUCCESS, 77 | } 78 | a.WriteMsg(retBuf) 79 | } 80 | } 81 | 82 | func handleUserLogin(args []interface{}) { 83 | m := args[0].(*msg.UserLogin) 84 | a := args[1].(gate.Agent) 85 | log.Debug("receive UserLogin name=%v", m.GetLoginName()) 86 | 87 | retBuf := &msg.UserResult{ 88 | RetResult: msg.Result_LOGIN_SUCCESS, 89 | ErrorInfo:"登陆失败,请稍后再试!", 90 | } 91 | a.WriteMsg(retBuf) 92 | } 93 | -------------------------------------------------------------------------------- /src/server/db/mongodb/mongodbmgr.go: -------------------------------------------------------------------------------- 1 | package mongodbmgr 2 | 3 | import ( 4 | "fmt" 5 | "github.com/name5566/leaf/db/mongodb" 6 | "github.com/name5566/leaf/log" 7 | "gopkg.in/mgo.v2" 8 | "gopkg.in/mgo.v2/bson" 9 | ) 10 | 11 | // 连接消息 12 | var dialContext = new(mongodb.DialContext) 13 | 14 | func init() { 15 | Connect() 16 | } 17 | func Connect() { 18 | c, err := mongodb.Dial("localhost", 10) 19 | if err != nil { 20 | fmt.Println(err) 21 | return 22 | } 23 | //defer c.Close() 24 | // index 25 | c.EnsureUniqueIndex("game", "login", []string{"name"}) 26 | log.Release("mongodb Connect success") 27 | dialContext = c 28 | 29 | Test() 30 | } 31 | func Test() { 32 | err :=Find("game","login",bson.M{"name":"hello"}) 33 | if err == nil { 34 | log.Debug("Test have data,regFail!", ) 35 | }else{ 36 | err =Insert("game","login",bson.M{"name":"hello","password":"123456"}) 37 | if err != nil { 38 | fmt.Println(err) 39 | log.Debug("Test write in fail", ) 40 | } 41 | } 42 | } 43 | 44 | func Example() { 45 | c, err := mongodb.Dial("localhost", 10) 46 | if err != nil { 47 | fmt.Println(err) 48 | return 49 | } 50 | defer c.Close() 51 | 52 | // session 53 | s := c.Ref() 54 | defer c.UnRef(s) 55 | err = s.DB("test").C("counters").RemoveId("test") 56 | if err != nil && err != mgo.ErrNotFound { 57 | fmt.Println(err) 58 | return 59 | } 60 | 61 | // auto increment 62 | err = c.EnsureCounter("test", "counters", "test") 63 | if err != nil { 64 | fmt.Println(err) 65 | return 66 | } 67 | for i := 0; i < 3; i++ { 68 | id, err := c.NextSeq("test", "counters", "test") 69 | if err != nil { 70 | fmt.Println(err) 71 | return 72 | } 73 | fmt.Println(id) 74 | } 75 | 76 | // index 77 | c.EnsureUniqueIndex("test", "counters", []string{"key1"}) 78 | 79 | // Output: 80 | // 1 81 | // 2 82 | // 3 83 | } 84 | 85 | func Find(db string, collection string, docs interface{}) error{ 86 | c:=dialContext 87 | s := c.Ref() 88 | defer c.UnRef(s) 89 | 90 | type person struct { 91 | Id_ bson.ObjectId `bson:"_id"` 92 | Name string `bson:"name"` 93 | }; 94 | user:=new(person); 95 | err := s.DB(db).C(collection).Find(docs).One(&user) 96 | //idStr:=user.Id_.Hex() 97 | //fmt.Println(idStr) 98 | if err != nil { 99 | fmt.Println(err) 100 | return err 101 | } 102 | 103 | return err; 104 | } 105 | 106 | // goroutine safe 107 | func Insert(db string, collection string, docs interface{}) error { 108 | c:=dialContext 109 | s := c.Ref() 110 | defer c.UnRef(s) 111 | 112 | //// 创建索引 113 | //index := mgo.Index{ 114 | // Key: []string{"name"}, // 索引字段, 默认升序,若需降序在字段前加- 115 | // Unique: true, // 唯一索引 同mysql唯一索引 116 | // DropDups: true, // 索引重复替换旧文档,Unique为true时失效 117 | // Background: true, // 后台创建索引 118 | //} 119 | //if err := s.DB(db).C(collection).EnsureIndex(index); err != nil { 120 | // fmt.Println(err) 121 | // return err 122 | //} 123 | //if err := s.DB(db).C(collection).EnsureIndexKey("$2dsphere:location"); err != nil { // 创建一个范围索引 124 | // fmt.Println(err) 125 | // return err 126 | //} 127 | 128 | err := s.DB(db).C(collection).Insert(docs) 129 | if err != nil { 130 | fmt.Println(err) 131 | return err 132 | } 133 | 134 | return err 135 | } 136 | -------------------------------------------------------------------------------- /src/server/msg/lobby.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: lobby.proto 3 | 4 | package msg 5 | 6 | import proto "github.com/golang/protobuf/proto" 7 | import fmt "fmt" 8 | import math "math" 9 | 10 | // Reference imports to suppress errors if they are not otherwise used. 11 | var _ = proto.Marshal 12 | var _ = fmt.Errorf 13 | var _ = math.Inf 14 | 15 | // This is a compile-time assertion to ensure that this generated file 16 | // is compatible with the proto package it is being compiled against. 17 | // A compilation error at this line likely means your copy of the 18 | // proto package needs to be updated. 19 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 20 | 21 | type Result int32 22 | 23 | const ( 24 | Result_REGISTER_SUCCESS Result = 0 25 | Result_REGISTER_FAIL Result = 1 26 | Result_LOGIN_SUCCESS Result = 2 27 | Result_LOGIN_FAIL Result = 3 28 | ) 29 | 30 | var Result_name = map[int32]string{ 31 | 0: "REGISTER_SUCCESS", 32 | 1: "REGISTER_FAIL", 33 | 2: "LOGIN_SUCCESS", 34 | 3: "LOGIN_FAIL", 35 | } 36 | var Result_value = map[string]int32{ 37 | "REGISTER_SUCCESS": 0, 38 | "REGISTER_FAIL": 1, 39 | "LOGIN_SUCCESS": 2, 40 | "LOGIN_FAIL": 3, 41 | } 42 | 43 | func (x Result) String() string { 44 | return proto.EnumName(Result_name, int32(x)) 45 | } 46 | func (Result) EnumDescriptor() ([]byte, []int) { 47 | return fileDescriptor_lobby_efee8445fc8fd304, []int{0} 48 | } 49 | 50 | type Test struct { 51 | Test string `protobuf:"bytes,2,opt,name=Test,proto3" json:"Test,omitempty"` 52 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 53 | XXX_unrecognized []byte `json:"-"` 54 | XXX_sizecache int32 `json:"-"` 55 | } 56 | 57 | func (m *Test) Reset() { *m = Test{} } 58 | func (m *Test) String() string { return proto.CompactTextString(m) } 59 | func (*Test) ProtoMessage() {} 60 | func (*Test) Descriptor() ([]byte, []int) { 61 | return fileDescriptor_lobby_efee8445fc8fd304, []int{0} 62 | } 63 | func (m *Test) XXX_Unmarshal(b []byte) error { 64 | return xxx_messageInfo_Test.Unmarshal(m, b) 65 | } 66 | func (m *Test) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 67 | return xxx_messageInfo_Test.Marshal(b, m, deterministic) 68 | } 69 | func (dst *Test) XXX_Merge(src proto.Message) { 70 | xxx_messageInfo_Test.Merge(dst, src) 71 | } 72 | func (m *Test) XXX_Size() int { 73 | return xxx_messageInfo_Test.Size(m) 74 | } 75 | func (m *Test) XXX_DiscardUnknown() { 76 | xxx_messageInfo_Test.DiscardUnknown(m) 77 | } 78 | 79 | var xxx_messageInfo_Test proto.InternalMessageInfo 80 | 81 | func (m *Test) GetTest() string { 82 | if m != nil { 83 | return m.Test 84 | } 85 | return "" 86 | } 87 | 88 | // 用户登陆协议 89 | type UserLogin struct { 90 | LoginName string `protobuf:"bytes,1,opt,name=LoginName,proto3" json:"LoginName,omitempty"` 91 | LoginPW string `protobuf:"bytes,2,opt,name=LoginPW,proto3" json:"LoginPW,omitempty"` 92 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 93 | XXX_unrecognized []byte `json:"-"` 94 | XXX_sizecache int32 `json:"-"` 95 | } 96 | 97 | func (m *UserLogin) Reset() { *m = UserLogin{} } 98 | func (m *UserLogin) String() string { return proto.CompactTextString(m) } 99 | func (*UserLogin) ProtoMessage() {} 100 | func (*UserLogin) Descriptor() ([]byte, []int) { 101 | return fileDescriptor_lobby_efee8445fc8fd304, []int{1} 102 | } 103 | func (m *UserLogin) XXX_Unmarshal(b []byte) error { 104 | return xxx_messageInfo_UserLogin.Unmarshal(m, b) 105 | } 106 | func (m *UserLogin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 107 | return xxx_messageInfo_UserLogin.Marshal(b, m, deterministic) 108 | } 109 | func (dst *UserLogin) XXX_Merge(src proto.Message) { 110 | xxx_messageInfo_UserLogin.Merge(dst, src) 111 | } 112 | func (m *UserLogin) XXX_Size() int { 113 | return xxx_messageInfo_UserLogin.Size(m) 114 | } 115 | func (m *UserLogin) XXX_DiscardUnknown() { 116 | xxx_messageInfo_UserLogin.DiscardUnknown(m) 117 | } 118 | 119 | var xxx_messageInfo_UserLogin proto.InternalMessageInfo 120 | 121 | func (m *UserLogin) GetLoginName() string { 122 | if m != nil { 123 | return m.LoginName 124 | } 125 | return "" 126 | } 127 | 128 | func (m *UserLogin) GetLoginPW() string { 129 | if m != nil { 130 | return m.LoginPW 131 | } 132 | return "" 133 | } 134 | 135 | // 注册协议 136 | type UserRegister struct { 137 | LoginName string `protobuf:"bytes,1,opt,name=LoginName,proto3" json:"LoginName,omitempty"` 138 | LoginPW string `protobuf:"bytes,2,opt,name=LoginPW,proto3" json:"LoginPW,omitempty"` 139 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 140 | XXX_unrecognized []byte `json:"-"` 141 | XXX_sizecache int32 `json:"-"` 142 | } 143 | 144 | func (m *UserRegister) Reset() { *m = UserRegister{} } 145 | func (m *UserRegister) String() string { return proto.CompactTextString(m) } 146 | func (*UserRegister) ProtoMessage() {} 147 | func (*UserRegister) Descriptor() ([]byte, []int) { 148 | return fileDescriptor_lobby_efee8445fc8fd304, []int{2} 149 | } 150 | func (m *UserRegister) XXX_Unmarshal(b []byte) error { 151 | return xxx_messageInfo_UserRegister.Unmarshal(m, b) 152 | } 153 | func (m *UserRegister) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 154 | return xxx_messageInfo_UserRegister.Marshal(b, m, deterministic) 155 | } 156 | func (dst *UserRegister) XXX_Merge(src proto.Message) { 157 | xxx_messageInfo_UserRegister.Merge(dst, src) 158 | } 159 | func (m *UserRegister) XXX_Size() int { 160 | return xxx_messageInfo_UserRegister.Size(m) 161 | } 162 | func (m *UserRegister) XXX_DiscardUnknown() { 163 | xxx_messageInfo_UserRegister.DiscardUnknown(m) 164 | } 165 | 166 | var xxx_messageInfo_UserRegister proto.InternalMessageInfo 167 | 168 | func (m *UserRegister) GetLoginName() string { 169 | if m != nil { 170 | return m.LoginName 171 | } 172 | return "" 173 | } 174 | 175 | func (m *UserRegister) GetLoginPW() string { 176 | if m != nil { 177 | return m.LoginPW 178 | } 179 | return "" 180 | } 181 | 182 | // 消息返回协议 183 | type UserResult struct { 184 | RetResult Result `protobuf:"varint,1,opt,name=RetResult,proto3,enum=msg.Result" json:"RetResult,omitempty"` 185 | ErrorInfo string `protobuf:"bytes,2,opt,name=ErrorInfo,proto3" json:"ErrorInfo,omitempty"` 186 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 187 | XXX_unrecognized []byte `json:"-"` 188 | XXX_sizecache int32 `json:"-"` 189 | } 190 | 191 | func (m *UserResult) Reset() { *m = UserResult{} } 192 | func (m *UserResult) String() string { return proto.CompactTextString(m) } 193 | func (*UserResult) ProtoMessage() {} 194 | func (*UserResult) Descriptor() ([]byte, []int) { 195 | return fileDescriptor_lobby_efee8445fc8fd304, []int{3} 196 | } 197 | func (m *UserResult) XXX_Unmarshal(b []byte) error { 198 | return xxx_messageInfo_UserResult.Unmarshal(m, b) 199 | } 200 | func (m *UserResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 201 | return xxx_messageInfo_UserResult.Marshal(b, m, deterministic) 202 | } 203 | func (dst *UserResult) XXX_Merge(src proto.Message) { 204 | xxx_messageInfo_UserResult.Merge(dst, src) 205 | } 206 | func (m *UserResult) XXX_Size() int { 207 | return xxx_messageInfo_UserResult.Size(m) 208 | } 209 | func (m *UserResult) XXX_DiscardUnknown() { 210 | xxx_messageInfo_UserResult.DiscardUnknown(m) 211 | } 212 | 213 | var xxx_messageInfo_UserResult proto.InternalMessageInfo 214 | 215 | func (m *UserResult) GetRetResult() Result { 216 | if m != nil { 217 | return m.RetResult 218 | } 219 | return Result_REGISTER_SUCCESS 220 | } 221 | 222 | func (m *UserResult) GetErrorInfo() string { 223 | if m != nil { 224 | return m.ErrorInfo 225 | } 226 | return "" 227 | } 228 | 229 | // 玩家有角色的情况 230 | type UserST struct { 231 | UID string `protobuf:"bytes,1,opt,name=UID,proto3" json:"UID,omitempty"` 232 | ServerID string `protobuf:"bytes,2,opt,name=ServerID,proto3" json:"ServerID,omitempty"` 233 | RoleUID string `protobuf:"bytes,3,opt,name=RoleUID,proto3" json:"RoleUID,omitempty"` 234 | RoleName string `protobuf:"bytes,4,opt,name=RoleName,proto3" json:"RoleName,omitempty"` 235 | RoleLev string `protobuf:"bytes,5,opt,name=RoleLev,proto3" json:"RoleLev,omitempty"` 236 | Coin string `protobuf:"bytes,6,opt,name=Coin,proto3" json:"Coin,omitempty"` 237 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 238 | XXX_unrecognized []byte `json:"-"` 239 | XXX_sizecache int32 `json:"-"` 240 | } 241 | 242 | func (m *UserST) Reset() { *m = UserST{} } 243 | func (m *UserST) String() string { return proto.CompactTextString(m) } 244 | func (*UserST) ProtoMessage() {} 245 | func (*UserST) Descriptor() ([]byte, []int) { 246 | return fileDescriptor_lobby_efee8445fc8fd304, []int{4} 247 | } 248 | func (m *UserST) XXX_Unmarshal(b []byte) error { 249 | return xxx_messageInfo_UserST.Unmarshal(m, b) 250 | } 251 | func (m *UserST) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 252 | return xxx_messageInfo_UserST.Marshal(b, m, deterministic) 253 | } 254 | func (dst *UserST) XXX_Merge(src proto.Message) { 255 | xxx_messageInfo_UserST.Merge(dst, src) 256 | } 257 | func (m *UserST) XXX_Size() int { 258 | return xxx_messageInfo_UserST.Size(m) 259 | } 260 | func (m *UserST) XXX_DiscardUnknown() { 261 | xxx_messageInfo_UserST.DiscardUnknown(m) 262 | } 263 | 264 | var xxx_messageInfo_UserST proto.InternalMessageInfo 265 | 266 | func (m *UserST) GetUID() string { 267 | if m != nil { 268 | return m.UID 269 | } 270 | return "" 271 | } 272 | 273 | func (m *UserST) GetServerID() string { 274 | if m != nil { 275 | return m.ServerID 276 | } 277 | return "" 278 | } 279 | 280 | func (m *UserST) GetRoleUID() string { 281 | if m != nil { 282 | return m.RoleUID 283 | } 284 | return "" 285 | } 286 | 287 | func (m *UserST) GetRoleName() string { 288 | if m != nil { 289 | return m.RoleName 290 | } 291 | return "" 292 | } 293 | 294 | func (m *UserST) GetRoleLev() string { 295 | if m != nil { 296 | return m.RoleLev 297 | } 298 | return "" 299 | } 300 | 301 | func (m *UserST) GetCoin() string { 302 | if m != nil { 303 | return m.Coin 304 | } 305 | return "" 306 | } 307 | 308 | func init() { 309 | proto.RegisterType((*Test)(nil), "msg.Test") 310 | proto.RegisterType((*UserLogin)(nil), "msg.UserLogin") 311 | proto.RegisterType((*UserRegister)(nil), "msg.UserRegister") 312 | proto.RegisterType((*UserResult)(nil), "msg.UserResult") 313 | proto.RegisterType((*UserST)(nil), "msg.UserST") 314 | proto.RegisterEnum("msg.Result", Result_name, Result_value) 315 | } 316 | 317 | func init() { proto.RegisterFile("lobby.proto", fileDescriptor_lobby_efee8445fc8fd304) } 318 | 319 | var fileDescriptor_lobby_efee8445fc8fd304 = []byte{ 320 | // 299 bytes of a gzipped FileDescriptorProto 321 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x51, 0xc1, 0x4e, 0x83, 0x40, 322 | 0x14, 0x94, 0x52, 0x51, 0x5e, 0xb5, 0xc1, 0x8d, 0x07, 0xd2, 0x78, 0x30, 0x9c, 0xd4, 0x43, 0x0f, 323 | 0xfa, 0x05, 0x86, 0xd2, 0x66, 0x13, 0x52, 0xcd, 0x2e, 0xc4, 0xa3, 0xb1, 0xc9, 0x4a, 0x9a, 0x00, 324 | 0x6b, 0x76, 0x91, 0xc4, 0x5f, 0xf1, 0x6b, 0xcd, 0xdb, 0x5d, 0xe0, 0xee, 0x89, 0x99, 0xe1, 0xcd, 325 | 0xec, 0x7b, 0x19, 0x58, 0xd4, 0xf2, 0x70, 0xf8, 0x59, 0x7f, 0x29, 0xd9, 0x49, 0xe2, 0x37, 0xba, 326 | 0x4a, 0x56, 0x30, 0x2f, 0x84, 0xee, 0x08, 0xb1, 0xdf, 0x78, 0x76, 0xeb, 0xdd, 0x85, 0xcc, 0xe0, 327 | 0x24, 0x85, 0xb0, 0xd4, 0x42, 0xe5, 0xb2, 0x3a, 0xb6, 0xe4, 0x06, 0x42, 0x03, 0xf6, 0x1f, 0x8d, 328 | 0x88, 0x3d, 0x33, 0x35, 0x09, 0x24, 0x86, 0x33, 0x43, 0x5e, 0xdf, 0x5c, 0xc2, 0x40, 0x93, 0x2d, 329 | 0x5c, 0x60, 0x08, 0x13, 0xd5, 0x51, 0x77, 0x42, 0xfd, 0x3b, 0xa7, 0x04, 0xb0, 0x39, 0xfa, 0xbb, 330 | 0xee, 0xc8, 0x3d, 0x84, 0x4c, 0x74, 0x96, 0x98, 0x94, 0xe5, 0xe3, 0x62, 0xdd, 0xe8, 0x6a, 0x6d, 331 | 0x25, 0x36, 0xfd, 0xc5, 0x07, 0x33, 0xa5, 0xa4, 0xa2, 0xed, 0xa7, 0x74, 0xa1, 0x93, 0x90, 0xfc, 332 | 0x7a, 0x10, 0x60, 0x2e, 0x2f, 0x48, 0x04, 0x7e, 0x49, 0x37, 0x6e, 0x27, 0x84, 0x64, 0x05, 0xe7, 333 | 0x5c, 0xa8, 0x5e, 0x28, 0xba, 0x71, 0xce, 0x91, 0xe3, 0xa6, 0x4c, 0xd6, 0x02, 0x1d, 0xbe, 0xdd, 334 | 0xd4, 0x51, 0x74, 0x21, 0x34, 0x07, 0xce, 0xad, 0x6b, 0xe0, 0x83, 0x2b, 0x17, 0x7d, 0x7c, 0x3a, 335 | 0xb9, 0x72, 0xd1, 0x63, 0x01, 0xa9, 0x3c, 0xb6, 0x71, 0x60, 0x0b, 0x40, 0xfc, 0x50, 0x40, 0xe0, 336 | 0x8e, 0xb8, 0x86, 0x88, 0x65, 0x3b, 0xca, 0x8b, 0x8c, 0xbd, 0xf3, 0x32, 0x4d, 0x33, 0xce, 0xa3, 337 | 0x13, 0x72, 0x05, 0x97, 0xa3, 0xba, 0x7d, 0xa6, 0x79, 0xe4, 0xa1, 0x94, 0xbf, 0xec, 0xe8, 0x7e, 338 | 0x9c, 0x9a, 0x91, 0x25, 0x80, 0x95, 0xcc, 0x88, 0x7f, 0x08, 0x4c, 0xfd, 0x4f, 0x7f, 0x01, 0x00, 339 | 0x00, 0xff, 0xff, 0x2a, 0x90, 0xd4, 0x4d, 0x0d, 0x02, 0x00, 0x00, 340 | } 341 | --------------------------------------------------------------------------------