Documentation ¶
Overview ¶
通讯协议处理,主要处理封包和解包的过程
Index ¶
- Constants
- func DecodePacket(r *bufio.Reader) (uint32, []byte, []byte, []byte, error)
- func EncodePacket(_type string, header []byte, payload []byte) ([]byte, error)
- func HubPack(cmd, sid, callback_seq string, payload []byte) ([]byte, error)
- func HubUnPack(r *bufio.Reader) ([]byte, []byte, []byte, []byte, error)
- type BaseRoot
- type BroatcastHeader
- type BroatcastRoot
- type ClientPacket
- type Json
- func (this *Json) GetBroatcastObj(data []byte) (*BroatcastRoot, error)
- func (this *Json) GetPushObj(data []byte) (*PushRoot, error)
- func (this *Json) GetReqObj(data []byte) (*ReqRoot, error)
- func (this *Json) GetRespObj(data []byte) (*ResponseRoot, error)
- func (this *Json) Init() *Json
- func (this *Json) WrapBroatcastRespObj(area_id string, from_sid string, data []byte) BroatcastRoot
- func (this *Json) WrapPushResp(to_sid string, from_sid string, data []byte) []byte
- func (this *Json) WrapPushRespObj(to_sid string, from_sid string, data []byte) PushRoot
- func (this *Json) WrapResp(header []byte, data []byte, status int, msg string) []byte
- func (this *Json) WrapRespErr(err string) []byte
- func (this *Json) WrapRespObj(req_obj *ReqRoot, invoker_ret []byte, status int) ResponseRoot
- type Pack
- func (this *Pack) GetBroatcastHeaderObj(header []byte) (*BroatcastHeader, error)
- func (this *Pack) GetBroatcastObj(data []byte) (*BroatcastRoot, error)
- func (this *Pack) GetPushObj(data []byte) (*PushRoot, error)
- func (this *Pack) GetReqHeaderObj(header []byte) (*ReqHeader, error)
- func (this *Pack) GetReqObj(_type uint32, header []byte, data []byte) (*ReqRoot, error)
- func (this *Pack) GetReqObjByReader(reader *bufio.Reader) (*ReqRoot, error)
- func (this *Pack) GetRespHeaderObj(header []byte) (*RespHeader, error)
- func (this *Pack) GetRespObj(_type uint32, header []byte, data []byte) (*ResponseRoot, error)
- func (this *Pack) Init() *Pack
- func (this *Pack) WrapBroatcastResp(area_id, from_sid string, data []byte) ([]byte, error)
- func (this *Pack) WrapBroatcastRespObj(area_id, from_sid string, data []byte) BroatcastRoot
- func (this *Pack) WrapPushResp(to_sid string, from_sid string, data_buf []byte) ([]byte, error)
- func (this *Pack) WrapPushRespObj(to_sid string, from_sid string, data []byte) PushRoot
- func (this *Pack) WrapReq(cmd, sid, token string, seq int, data []byte) ([]byte, error)
- func (this *Pack) WrapReqWithHeader(req_header *ReqHeader, data []byte) ([]byte, error)
- func (this *Pack) WrapResp(cmd, req_sid string, seq int, status int, data []byte) ([]byte, error)
- func (this *Pack) WrapRespErr(err string) ([]byte, error)
- func (this *Pack) WrapRespObj(req_obj *ReqRoot, invoker_ret []byte, status int) ResponseRoot
- type ProtocolType
- type PushHeader
- type PushRoot
- type ReqHeader
- type ReqRoot
- type RespHeader
- type ResponseRoot
Constants ¶
View Source
const TypeBroatcast = "3"
View Source
const TypeError = "5"
View Source
const TypePing = "7"
View Source
const TypePush = "4"
View Source
const TypeReply = "6"
View Source
const TypeReq = "1"
View Source
const TypeResp = "2"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BroatcastHeader ¶
type BroatcastRoot ¶
type BroatcastRoot struct { Type string `json:"type"` Header BroatcastHeader `json:"header"` Data interface{} `json:"data"` }
type ClientPacket ¶
type ClientPacket struct { TotalSize uint32 //4 Type uint8 HeaderSize uint32 //4 Header []byte Payload []byte Checksum uint32 //4 }
|总长度4|type4|头长度4|header|data|checksum
type Json ¶
type Json struct { ProtocolObj ProtocolType Data []byte }
func (*Json) GetBroatcastObj ¶
func (this *Json) GetBroatcastObj(data []byte) (*BroatcastRoot, error)
func (*Json) GetRespObj ¶
func (this *Json) GetRespObj(data []byte) (*ResponseRoot, error)
func (*Json) WrapBroatcastRespObj ¶
func (this *Json) WrapBroatcastRespObj(area_id string, from_sid string, data []byte) BroatcastRoot
func (*Json) WrapPushResp ¶
func (*Json) WrapPushRespObj ¶
func (*Json) WrapRespObj ¶
func (this *Json) WrapRespObj(req_obj *ReqRoot, invoker_ret []byte, status int) ResponseRoot
type Pack ¶
type Pack struct { ProtocolObj ProtocolType Data []byte }
func (*Pack) GetBroatcastHeaderObj ¶
func (this *Pack) GetBroatcastHeaderObj(header []byte) (*BroatcastHeader, error)
func (*Pack) GetBroatcastObj ¶
func (this *Pack) GetBroatcastObj(data []byte) (*BroatcastRoot, error)
func (*Pack) GetReqObjByReader ¶
func (*Pack) GetRespHeaderObj ¶
func (this *Pack) GetRespHeaderObj(header []byte) (*RespHeader, error)
func (*Pack) GetRespObj ¶
func (*Pack) WrapBroatcastResp ¶
func (*Pack) WrapBroatcastRespObj ¶
func (this *Pack) WrapBroatcastRespObj(area_id, from_sid string, data []byte) BroatcastRoot
func (*Pack) WrapPushResp ¶
func (*Pack) WrapPushRespObj ¶
func (*Pack) WrapReqWithHeader ¶
func (*Pack) WrapRespObj ¶
func (this *Pack) WrapRespObj(req_obj *ReqRoot, invoker_ret []byte, status int) ResponseRoot
type ProtocolType ¶
type ProtocolType struct { ReqObj ReqRoot RespObj ResponseRoot BroatcastObj BroatcastRoot PushObj PushRoot Init func() }
type PushHeader ¶
type PushHeader struct {
Sid string `json:"sid"`
}
type PushRoot ¶
type PushRoot struct { Type string `json:"type"` Header PushHeader `json:"header"` Data interface{} `json:"data"` }
type RespHeader ¶
type ResponseRoot ¶
type ResponseRoot struct { Type string `json:"type"` Header RespHeader `json:"header"` Data []byte `json:"data"` }
Click to show internal directories.
Click to hide internal directories.