protocol

package
v0.0.0-...-93dd735 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2016 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Overview

Package protocol is a generated protocol buffer package.

It is generated from these files:

message.proto
session.proto
sync.proto

It has these top-level messages:

Message
LoginReq
LoginRsp
OfflineNotify
StatusNotify
SyncNotify
SyncReq
SyncRsp

Index

Constants

View Source
const (
	SYNC_ID_PREFIX          = "sync_id_"
	SYNC_PREFIX             = "sync_"
	SYNC_HEAD_OFFSET_PREFIX = "sync_head_offset_"
)
View Source
const Default_LoginRsp_Code int32 = 0
View Source
const (
	KEY_TTL = 3600 * 24 * 365 // one year
)

Variables

View Source
var BaseBiz_name = map[int32]string{
	1: "SESSION",
	2: "FRIENDS",
	3: "MESSAGE",
	4: "GROUP",
}
View Source
var BaseBiz_value = map[string]int32{
	"SESSION": 1,
	"FRIENDS": 2,
	"MESSAGE": 3,
	"GROUP":   4,
}
View Source
var BaseCMD_name = map[int32]string{
	100: "ACK",
	101: "NTY_SYNC",
	102: "REQ_SYNC",
	103: "RSP_SYNC",
	200: "REQ_LOGIN",
	201: "RSP_LOGIN",
}
View Source
var BaseCMD_value = map[string]int32{
	"ACK":       100,
	"NTY_SYNC":  101,
	"REQ_SYNC":  102,
	"RSP_SYNC":  103,
	"REQ_LOGIN": 200,
	"RSP_LOGIN": 201,
}
View Source
var Equiment_name = map[int32]string{
	1: "PC",
	2: "WEB",
	3: "ANDROID",
	4: "IOS",
}
View Source
var Equiment_value = map[string]int32{
	"PC":      1,
	"WEB":     2,
	"ANDROID": 3,
	"IOS":     4,
}
View Source
var RouterCMD_name = map[int32]string{
	0:  "SESSION_CLOSED",
	1:  "SESSION_CLOSED_COMPLETE",
	10: "CHANGE_ROUTER",
	99: "HEATBEAT",
}
View Source
var RouterCMD_value = map[string]int32{
	"SESSION_CLOSED":          0,
	"SESSION_CLOSED_COMPLETE": 1,
	"CHANGE_ROUTER":           10,
	"HEATBEAT":                99,
}
View Source
var Status_name = map[int32]string{
	1: "ONLINE",
	2: "OFFLINE",
}
View Source
var Status_value = map[string]int32{
	"ONLINE":  1,
	"OFFLINE": 2,
}

Functions

func NewProtobufDecoder

func NewProtobufDecoder() goetty.Decoder

func NewProtobufEncoder

func NewProtobufEncoder() goetty.Encoder

Types

type BaseBiz

type BaseBiz int32
const (
	BaseBiz_SESSION BaseBiz = 1
	BaseBiz_FRIENDS BaseBiz = 2
	BaseBiz_MESSAGE BaseBiz = 3
	BaseBiz_GROUP   BaseBiz = 4
)

func (BaseBiz) Enum

func (x BaseBiz) Enum() *BaseBiz

func (BaseBiz) EnumDescriptor

func (BaseBiz) EnumDescriptor() ([]byte, []int)

func (BaseBiz) String

func (x BaseBiz) String() string

func (*BaseBiz) UnmarshalJSON

func (x *BaseBiz) UnmarshalJSON(data []byte) error

type BaseCMD

type BaseCMD int32
const (
	// ack
	BaseCMD_ACK BaseCMD = 100
	// sync protocol about
	BaseCMD_NTY_SYNC BaseCMD = 101
	BaseCMD_REQ_SYNC BaseCMD = 102
	BaseCMD_RSP_SYNC BaseCMD = 103
	// session about
	BaseCMD_REQ_LOGIN BaseCMD = 200
	BaseCMD_RSP_LOGIN BaseCMD = 201
)

func (BaseCMD) Enum

func (x BaseCMD) Enum() *BaseCMD

func (BaseCMD) EnumDescriptor

func (BaseCMD) EnumDescriptor() ([]byte, []int)

func (BaseCMD) String

func (x BaseCMD) String() string

func (*BaseCMD) UnmarshalJSON

func (x *BaseCMD) UnmarshalJSON(data []byte) error

type Equiment

type Equiment int32
const (
	Equiment_PC      Equiment = 1
	Equiment_WEB     Equiment = 2
	Equiment_ANDROID Equiment = 3
	Equiment_IOS     Equiment = 4
)

func (Equiment) Enum

func (x Equiment) Enum() *Equiment

func (Equiment) EnumDescriptor

func (Equiment) EnumDescriptor() ([]byte, []int)

func (Equiment) String

func (x Equiment) String() string

func (*Equiment) UnmarshalJSON

func (x *Equiment) UnmarshalJSON(data []byte) error

type LoginReq

type LoginReq struct {
	Name             *string   `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	Password         *string   `protobuf:"bytes,2,req,name=password" json:"password,omitempty"`
	Equiment         *Equiment `protobuf:"varint,3,req,name=equiment,enum=protocol.Equiment" json:"equiment,omitempty"`
	Status           *Status   `protobuf:"varint,4,opt,name=status,enum=protocol.Status,def=1" json:"status,omitempty"`
	XXX_unrecognized []byte    `json:"-"`
}

func (*LoginReq) Descriptor

func (*LoginReq) Descriptor() ([]byte, []int)

func (*LoginReq) GetEquiment

func (m *LoginReq) GetEquiment() Equiment

func (*LoginReq) GetName

func (m *LoginReq) GetName() string

func (*LoginReq) GetPassword

func (m *LoginReq) GetPassword() string

func (*LoginReq) GetStatus

func (m *LoginReq) GetStatus() Status

func (*LoginReq) ProtoMessage

func (*LoginReq) ProtoMessage()

func (*LoginReq) Reset

func (m *LoginReq) Reset()

func (*LoginReq) String

func (m *LoginReq) String() string

type LoginRsp

type LoginRsp struct {
	Code             *int32  `protobuf:"varint,1,req,name=code,def=0" json:"code,omitempty"`
	Token            *string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
	Timeout          *int64  `protobuf:"varint,3,opt,name=timeout" json:"timeout,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*LoginRsp) Descriptor

func (*LoginRsp) Descriptor() ([]byte, []int)

func (*LoginRsp) GetCode

func (m *LoginRsp) GetCode() int32

func (*LoginRsp) GetTimeout

func (m *LoginRsp) GetTimeout() int64

func (*LoginRsp) GetToken

func (m *LoginRsp) GetToken() string

func (*LoginRsp) ProtoMessage

func (*LoginRsp) ProtoMessage()

func (*LoginRsp) Reset

func (m *LoginRsp) Reset()

func (*LoginRsp) String

func (m *LoginRsp) String() string

type Message

type Message struct {
	Cmd              *int32  `protobuf:"varint,1,req,name=cmd" json:"cmd,omitempty"`
	Biz              *int32  `protobuf:"varint,2,opt,name=biz" json:"biz,omitempty"`
	Product          *int32  `protobuf:"varint,3,opt,name=product" json:"product,omitempty"`
	CliVersion       *int32  `protobuf:"varint,4,opt,name=cliVersion" json:"cliVersion,omitempty"`
	CliSeqId         *int32  `protobuf:"varint,5,opt,name=cliSeqId" json:"cliSeqId,omitempty"`
	ProtocolVersion  *int32  `protobuf:"varint,6,opt,name=protocolVersion" json:"protocolVersion,omitempty"`
	SessionId        *string `protobuf:"bytes,7,opt,name=sessionId" json:"sessionId,omitempty"`
	MsgId            *string `protobuf:"bytes,8,opt,name=msgId" json:"msgId,omitempty"`
	Data             []byte  `protobuf:"bytes,9,opt,name=data" json:"data,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

router -> backend, exclude RouterCMD

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetBiz

func (m *Message) GetBiz() int32

func (*Message) GetCliSeqId

func (m *Message) GetCliSeqId() int32

func (*Message) GetCliVersion

func (m *Message) GetCliVersion() int32

func (*Message) GetCmd

func (m *Message) GetCmd() int32

func (*Message) GetData

func (m *Message) GetData() []byte

func (*Message) GetMsgId

func (m *Message) GetMsgId() string

func (*Message) GetProduct

func (m *Message) GetProduct() int32

func (*Message) GetProtocolVersion

func (m *Message) GetProtocolVersion() int32

func (*Message) GetSessionId

func (m *Message) GetSessionId() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

type OfflineNotify

type OfflineNotify struct {
	Code             *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

backend -> client when client received this message, the session is closed by backend, client should be disconnect the connection

func (*OfflineNotify) Descriptor

func (*OfflineNotify) Descriptor() ([]byte, []int)

func (*OfflineNotify) GetCode

func (m *OfflineNotify) GetCode() int32

func (*OfflineNotify) ProtoMessage

func (*OfflineNotify) ProtoMessage()

func (*OfflineNotify) Reset

func (m *OfflineNotify) Reset()

func (*OfflineNotify) String

func (m *OfflineNotify) String() string

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool() *Pool

func (*Pool) Get

func (p *Pool) Get() *Message

func (*Pool) Put

func (p *Pool) Put(msg interface{})

type ProtobufDecoder

type ProtobufDecoder struct {
}

func (ProtobufDecoder) Decode

func (self ProtobufDecoder) Decode(in *goetty.ByteBuf) (bool, interface{}, error)

type ProtobufEncoder

type ProtobufEncoder struct {
}

func (ProtobufEncoder) Encode

func (self ProtobufEncoder) Encode(data interface{}, out *goetty.ByteBuf) error

type RedisSyncProtocol

type RedisSyncProtocol struct {
	// contains filtered or unexported fields
}

func (RedisSyncProtocol) Clear

func (self RedisSyncProtocol) Clear(id string) error

func (RedisSyncProtocol) Create

func (self RedisSyncProtocol) Create(id string) error

func (RedisSyncProtocol) Get

func (self RedisSyncProtocol) Get(id string, count int64, offset int64) ([]*Message, int64, error)

func (RedisSyncProtocol) Rename

func (self RedisSyncProtocol) Rename(oldId string, newId string) error

func (RedisSyncProtocol) Set

func (self RedisSyncProtocol) Set(id string, msgs ...*Message) (int64, error)

func (RedisSyncProtocol) SetTimeout

func (self RedisSyncProtocol) SetTimeout(id string, seconds int) error

type RouterCMD

type RouterCMD int32
const (
	RouterCMD_SESSION_CLOSED          RouterCMD = 0
	RouterCMD_SESSION_CLOSED_COMPLETE RouterCMD = 1
	RouterCMD_CHANGE_ROUTER           RouterCMD = 10
	RouterCMD_HEATBEAT                RouterCMD = 99
)

func (RouterCMD) Enum

func (x RouterCMD) Enum() *RouterCMD

func (RouterCMD) EnumDescriptor

func (RouterCMD) EnumDescriptor() ([]byte, []int)

func (RouterCMD) String

func (x RouterCMD) String() string

func (*RouterCMD) UnmarshalJSON

func (x *RouterCMD) UnmarshalJSON(data []byte) error

type Status

type Status int32
const (
	Status_ONLINE  Status = 1
	Status_OFFLINE Status = 2
)
const Default_LoginReq_Status Status = Status_ONLINE

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor

func (Status) EnumDescriptor() ([]byte, []int)

func (Status) String

func (x Status) String() string

func (*Status) UnmarshalJSON

func (x *Status) UnmarshalJSON(data []byte) error

type StatusNotify

type StatusNotify struct {
	UserId           *int32    `protobuf:"varint,1,req,name=userId" json:"userId,omitempty"`
	Equiment         *Equiment `protobuf:"varint,2,req,name=equiment,enum=protocol.Equiment" json:"equiment,omitempty"`
	Status           *Status   `protobuf:"varint,3,req,name=status,enum=protocol.Status" json:"status,omitempty"`
	XXX_unrecognized []byte    `json:"-"`
}

func (*StatusNotify) Descriptor

func (*StatusNotify) Descriptor() ([]byte, []int)

func (*StatusNotify) GetEquiment

func (m *StatusNotify) GetEquiment() Equiment

func (*StatusNotify) GetStatus

func (m *StatusNotify) GetStatus() Status

func (*StatusNotify) GetUserId

func (m *StatusNotify) GetUserId() int32

func (*StatusNotify) ProtoMessage

func (*StatusNotify) ProtoMessage()

func (*StatusNotify) Reset

func (m *StatusNotify) Reset()

func (*StatusNotify) String

func (m *StatusNotify) String() string

type SyncNotify

type SyncNotify struct {
	Offset           *int64 `protobuf:"varint,1,req,name=offset" json:"offset,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

func (*SyncNotify) Descriptor

func (*SyncNotify) Descriptor() ([]byte, []int)

func (*SyncNotify) GetOffset

func (m *SyncNotify) GetOffset() int64

func (*SyncNotify) ProtoMessage

func (*SyncNotify) ProtoMessage()

func (*SyncNotify) Reset

func (m *SyncNotify) Reset()

func (*SyncNotify) String

func (m *SyncNotify) String() string

type SyncProtocol

type SyncProtocol interface {
	Clear(id string) error
	Create(id string) error
	Rename(oldId string, newId string) error
	SetTimeout(id string, seconds int) error
	Set(id string, msgs ...*Message) (maxOffset int64, err error)
	Get(id string, count int64, offset int64) (messages []*Message, readedOffset int64, err error)
}

sync protocol server -> client sync_notify client -> server sync_req server -> client sync_rsp server side use queue store messages, client use offset to get message. server received a sync message, delete messages which index is less than the client offset, and return the messages which index between offset+1 and offset+count

func NewRedisSyncProtocol

func NewRedisSyncProtocol(pool *redis.Pool) SyncProtocol

type SyncReq

type SyncReq struct {
	Offset           *int64 `protobuf:"varint,1,req,name=offset" json:"offset,omitempty"`
	Count            *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

func (*SyncReq) Descriptor

func (*SyncReq) Descriptor() ([]byte, []int)

func (*SyncReq) GetCount

func (m *SyncReq) GetCount() int32

func (*SyncReq) GetOffset

func (m *SyncReq) GetOffset() int64

func (*SyncReq) ProtoMessage

func (*SyncReq) ProtoMessage()

func (*SyncReq) Reset

func (m *SyncReq) Reset()

func (*SyncReq) String

func (m *SyncReq) String() string

type SyncRsp

type SyncRsp struct {
	Offset           *int64     `protobuf:"varint,1,req,name=offset" json:"offset,omitempty"`
	Messages         []*Message `protobuf:"bytes,2,rep,name=messages" json:"messages,omitempty"`
	XXX_unrecognized []byte     `json:"-"`
}

func (*SyncRsp) Descriptor

func (*SyncRsp) Descriptor() ([]byte, []int)

func (*SyncRsp) GetMessages

func (m *SyncRsp) GetMessages() []*Message

func (*SyncRsp) GetOffset

func (m *SyncRsp) GetOffset() int64

func (*SyncRsp) ProtoMessage

func (*SyncRsp) ProtoMessage()

func (*SyncRsp) Reset

func (m *SyncRsp) Reset()

func (*SyncRsp) String

func (m *SyncRsp) String() string

Jump to

Keyboard shortcuts

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