【全栈游戏开发】--服务器协议定义

| 【全栈游戏开发】--服务器协议定义


一 源码地址:https://github.com/Golangltd/codeclass

image

二 协议


image

Proto.go

package Proto

/*
  主协议
*/
const (
        ProtoINIT   = iota
        ProtoGopher // ProtoGopher == 1  地鼠的协议

)

//------------------------------------------------------------------------------

/*
  子协议
*/
const (
        Proto2INIT            = iota // 初始化
        C2S_PlayerLoginProto2        // C2S_PlayerLoginProto2 == 1  用户登录协议
        S2C_PlayerLoginProto2        // S2C_PlayerLoginProto2 == 2
)

//------------------------------------------------------------------------------
// 用户登录或者注册
type C2S_PlayerLogin struct {
        Protocol  int
        Protocol2 int
        Itype     int // 1:表示注册,2:表示登录
        LoginName string
        LoginPW   string
}

type S2C_PlayerLogin struct {
        Protocol  int
        Protocol2 int
        Token     string
}

//------------------------------------------------------------------------------

协议定义主要采用自定义协议吗,通过json传递。

全栈开发--地鼠 全部视频 ByteEdu.Com

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容