MCPcopy
hub / github.com/aceld/zinx / Intercept

Method Intercept

zdecoder/htlvcrcdecoder.go:118–146  ·  view source on GitHub ↗
(chain ziface.IChain)

Source from the content-addressed store, hash-verified

116}
117
118func (hcd *HtlvCrcDecoder) Intercept(chain ziface.IChain) ziface.IcResp {
119 //1. Get the IMessage of zinx
120 iMessage := chain.GetIMessage()
121 if iMessage == nil {
122 // Go to the next layer in the chain of responsibility
123 return chain.ProceedWithIMessage(iMessage, nil)
124 }
125
126 //2. Get Data
127 data := iMessage.GetData()
128 //zlog.Ins().DebugF("HTLVCRC-RawData size:%d data:%s\n", len(data), hex.EncodeToString(data))
129
130 //3. If the amount of data read is less than the length of the header, proceed to the next layer directly.
131 // (读取的数据不超过包头,直接进入下一层)
132 if len(data) < HEADER_SIZE {
133 return chain.ProceedWithIMessage(iMessage, nil)
134 }
135
136 //4. HTLV+CRC Decode
137 htlvData := hcd.decode(data)
138
139 //5. Set the decoded data back to the IMessage, the Zinx Router needs MsgID for addressing
140 // (将解码后的数据重新设置到IMessage中, Zinx的Router需要MsgID来寻址)
141 iMessage.SetMsgID(uint32(htlvData.Funcode))
142
143 //6. Pass the decoded data to the next layer.
144 // (将解码后的数据进入下一层)
145 return chain.ProceedWithIMessage(iMessage, *htlvData)
146}

Callers

nothing calls this directly

Calls 5

decodeMethod · 0.95
GetIMessageMethod · 0.65
ProceedWithIMessageMethod · 0.65
GetDataMethod · 0.65
SetMsgIDMethod · 0.65

Tested by

no test coverage detected