MCPcopy Index your code
hub / github.com/aceld/zinx / Intercept

Method Intercept

zdecoder/ltvdecoder_little.go:114–144  ·  view source on GitHub ↗
(chain ziface.IChain)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected