Documentation
¶
Index ¶
- func CreateMessageByID(msgId int32) proto.Message
- func CreateMessageByName(name string) proto.Message
- func CreatePairingAck(req proto.Message) proto.Message
- func CreatePairingAckBy(reqName string) proto.Message
- func GetMessageIDByName(msgName string) int32
- func GetMessageIDOf(msg proto.Message) int32
- func GetMessageNameByID(msgId int32) string
- func GetPairingAckID(reqId int32) int32
- func GetPairingAckName(reqName string) string
- func MessageToString(msg proto.Message) string
- func RegisterMsgID(exName string)
- type Packet
- func (m *Packet) AddRefers(v ...fatchoy.NodeID)
- func (m *Packet) Body() interface{}
- func (m *Packet) BodyToBytes() []byte
- func (m *Packet) BodyToFloat() float64
- func (m *Packet) BodyToInt() int64
- func (m *Packet) BodyToString() string
- func (m *Packet) Clone() fatchoy.IPacket
- func (m *Packet) Command() int32
- func (m *Packet) Decode() error
- func (m *Packet) DecodeTo(msg proto.Message) error
- func (m *Packet) Endpoint() fatchoy.MessageEndpoint
- func (m *Packet) Errno() int32
- func (m *Packet) Flag() fatchoy.PacketFlag
- func (m *Packet) Node() fatchoy.NodeID
- func (m *Packet) Refers() []fatchoy.NodeID
- func (m *Packet) Refuse(errno int32) error
- func (m *Packet) RefuseWith(command, errno int32) error
- func (m *Packet) Reply(command int32, body interface{}) error
- func (m *Packet) ReplyMsg(ack proto.Message) error
- func (m *Packet) Reset()
- func (m *Packet) Seq() uint16
- func (m *Packet) SetBody(val interface{})
- func (m *Packet) SetCommand(v int32)
- func (m *Packet) SetEndpoint(endpoint fatchoy.MessageEndpoint)
- func (m *Packet) SetErrno(ec int32)
- func (m *Packet) SetFlag(v fatchoy.PacketFlag)
- func (m *Packet) SetNode(n fatchoy.NodeID)
- func (m *Packet) SetRefers(v []fatchoy.NodeID)
- func (m *Packet) SetSeq(v uint16)
- func (m *Packet) SetType(v fatchoy.PacketType)
- func (m Packet) String() string
- func (m *Packet) Type() fatchoy.PacketType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePairingAck ¶
如果消息的名字是XXXReq,则尝试创建与其名称对应的XXXAck消息
func CreatePairingAckBy ¶
如果消息的名字是XXXReq,则尝试创建与其名称对应的XXXAck消息
func GetMessageIDByName ¶
func GetMessageNameByID ¶ added in v1.3.10
func MessageToString ¶ added in v1.3.15
func RegisterMsgID ¶
func RegisterMsgID(exName string)
Types ¶
type Packet ¶
type Packet struct { Cmd int32 `json:"cmd"` // 协议ID Seq_ uint16 `json:"seq"` // 序列号 Type_ fatchoy.PacketType `json:"typ,omitempty"` // 类型 Flg fatchoy.PacketFlag `json:"flg,omitempty"` // 标志位 Node_ fatchoy.NodeID `json:"node,omitempty"` // 源/目标节点 Body_ interface{} `json:"body,omitempty"` // 消息内容,int64/float64/string/bytes/proto.Message Refers_ []fatchoy.NodeID `json:"ref,omitempty"` // 组播session列表 // contains filtered or unexported fields }
Packet表示一个应用层消息
func (*Packet) BodyToBytes ¶ added in v1.2.0
将body转为[]byte,用于网络传输
func (*Packet) RefuseWith ¶ added in v1.2.0
func (*Packet) SetCommand ¶
func (*Packet) SetEndpoint ¶
func (m *Packet) SetEndpoint(endpoint fatchoy.MessageEndpoint)
Click to show internal directories.
Click to hide internal directories.