proto

package
v0.0.0-...-2b30333 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// size
	PackSize      = 4
	HeaderSize    = 2
	VerSize       = 2
	OperationSize = 4
	SeqIdSize     = 4
	RawHeaderSize = PackSize + HeaderSize + VerSize + OperationSize + SeqIdSize
	MaxPackSize   = MaxBodySize + int32(RawHeaderSize)
	// offset
	PackOffset      = 0
	HeaderOffset    = PackOffset + PackSize
	VerOffset       = HeaderOffset + HeaderSize
	OperationOffset = VerOffset + VerSize
	SeqIdOffset     = OperationOffset + OperationSize
)
View Source
const (
	MaxBodySize = int32(1 << 10)
)

for tcp

Variables

View Source
var (
	ErrProtoPackLen   = errors.New("default server codec pack length error")
	ErrProtoHeaderLen = errors.New("default server codec header length error")
)
View Source
var (
	ProtoReady  = &Proto{Operation: define.OP_PROTO_READY}
	ProtoFinish = &Proto{Operation: define.OP_PROTO_FINISH}
)

Functions

This section is empty.

Types

type AllRoomCountReply

type AllRoomCountReply struct {
	Counter map[int32]int32
}

type AllServerCountReply

type AllServerCountReply struct {
	Counter map[int32]int32
}

type BoardcastArg

type BoardcastArg struct {
	P Proto
}

type BoardcastRoomArg

type BoardcastRoomArg struct {
	RoomId int32
	P      Proto
}

type ConnArg

type ConnArg struct {
	Token  string
	Server int32
}

type ConnReply

type ConnReply struct {
	Key    string
	RoomId int32
}

type CountReply

type CountReply struct {
	Count int32
}

type DelArg

type DelArg struct {
	UserId int64
	Seq    int32
	RoomId int32
}

type DelReply

type DelReply struct {
	Has bool
}

type DelServerArg

type DelServerArg struct {
	Server int32
}

type DisconnArg

type DisconnArg struct {
	Key    string
	RoomId int32
}

type DisconnReply

type DisconnReply struct {
	Has bool
}

type GetAllReply

type GetAllReply struct {
	UserIds  []int64
	Sessions []*GetReply
}

type GetArg

type GetArg struct {
	UserId int64
}

type GetReply

type GetReply struct {
	Seqs    []int32
	Servers []int32
}

type KafkaMsg

type KafkaMsg struct {
	OP       string   `json:"op"`
	RoomId   int32    `json:"roomid,omitempty"`
	ServerId int32    `json:"server,omitempty"`
	SubKeys  []string `json:"subkeys,omitempty"`
	Msg      []byte   `json:"msg"`
	Ensure   bool     `json:"ensure,omitempty"`
}

TODO optimize struct after replace kafka

type MGetArg

type MGetArg struct {
	UserIds []int64
}

type MGetReply

type MGetReply struct {
	UserIds  []int64
	Sessions []*GetReply
}

type MPushMsgArg

type MPushMsgArg struct {
	Keys []string
	P    Proto
}

type MPushMsgReply

type MPushMsgReply struct {
	Index int32
}

type MPushMsgsArg

type MPushMsgsArg struct {
	PMArgs []*PushMsgArg
}

type MPushMsgsReply

type MPushMsgsReply struct {
	Index int32
}

type NoArg

type NoArg struct {
}

type NoReply

type NoReply struct {
}

type Proto

type Proto struct {
	Ver       int16           `json:"ver"`  // protocol version
	Operation int32           `json:"op"`   // operation for request
	SeqId     int32           `json:"seq"`  // sequence number chosen by client
	Body      json.RawMessage `json:"body"` // binary body bytes(json.RawMessage is []byte)
}

Proto is a request&response written before every goim connect. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic. tcp: binary codec websocket & http: raw codec, with http header stored ver, operation, seqid

func (*Proto) ReadTCP

func (p *Proto) ReadTCP(rr *bufio.Reader) (err error)

func (*Proto) ReadWebsocket

func (p *Proto) ReadWebsocket(wr *websocket.Conn) (err error)

func (*Proto) Reset

func (p *Proto) Reset()

func (*Proto) String

func (p *Proto) String() string

func (*Proto) WriteBodyTo

func (p *Proto) WriteBodyTo(b *bytes.Writer) (err error)

func (*Proto) WriteTCP

func (p *Proto) WriteTCP(wr *bufio.Writer) (err error)

func (*Proto) WriteTo

func (p *Proto) WriteTo(b *bytes.Writer)

func (*Proto) WriteWebsocket

func (p *Proto) WriteWebsocket(wr *websocket.Conn) (err error)

type PushMsgArg

type PushMsgArg struct {
	Key string
	P   Proto
}

type PushMsgsArg

type PushMsgsArg struct {
	Key    string
	PMArgs []*PushMsgArg
}

type PushMsgsReply

type PushMsgsReply struct {
	Index int32
}

type PutArg

type PutArg struct {
	UserId int64
	Server int32
	RoomId int32
}

type PutReply

type PutReply struct {
	Seq int32
}

type RoomCountArg

type RoomCountArg struct {
	RoomId int32
}

type RoomCountReply

type RoomCountReply struct {
	Count int32
}

type RoomsReply

type RoomsReply struct {
	RoomIds map[int32]struct{}
}

type UserCountArg

type UserCountArg struct {
	UserId int64
}

type UserCountReply

type UserCountReply struct {
	Count int32
}

Jump to

Keyboard shortcuts

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