proto

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

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

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

Documentation

Index

Constants

View Source
const (
	// group id
	PrivateGroupId = 0
	PublicGroupId  = 1
)
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}
)
View Source
var (
	ErrParam = errors.New("parameter error")
)

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 Message

type Message struct {
	Msg     []byte `json:"msg"` // message content
	MsgId   int64  `json:"mid"` // message id
	GroupId uint   `json:"gid"` // group id
}

The Message struct

type MessageGetPrivateArgs

type MessageGetPrivateArgs struct {
	MsgId int64  // message id
	Key   string // subscriber key
}

Message Get args

type MessageGetResp

type MessageGetResp struct {
	Msgs []*Message // messages
}

Message Get Response

type MessageSavePrivateArgs

type MessageSavePrivateArgs struct {
	Key    string // subscriber key
	Msg    []byte // message content
	MsgId  int64  // message id
	Expire uint   // message expire second
}

type MessageSavePrivatesArgs

type MessageSavePrivatesArgs struct {
	Keys   []string        // subscriber keys
	Msg    json.RawMessage // message content
	MsgId  int64           // message id
	Expire uint            // message expire second
}

Message SavePrivates args

type MessageSavePrivatesResp

type MessageSavePrivatesResp struct {
	FKeys []string // failed key
}

Message SavePrivates response

type MessageSavePublishArgs

type MessageSavePublishArgs struct {
	MsgID  int64  // message id
	Msg    string // message content
	Expire int64  // message expire second
}

Message SavePublish args

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 imgo 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 []int32
}

type Token

type Token struct {
	Token       string
	Uid, Expire int64
}

type MessageSaveTokenArgs struct { Key, Value string Expire int64 }

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