- repliesLock.Lock()
- defer repliesLock.Unlock()
-
- // pop all replies from queue
- for i, reply := range replies {
- if i > 0 && reply.GetMessageName() == "control_ping_reply" {
- // hack - do not send control_ping_reply immediately, leave it for the the next callback
- replies = []api.Message{}
- replies = append(replies, reply)
- return nil
+ a.repliesLock.Lock()
+ defer a.repliesLock.Unlock()
+
+ // pop the first reply
+ if len(a.replies) > 0 {
+ reply := a.replies[0]
+ for _, msg := range reply.msgs {
+ msgID, _ := a.GetMsgID(msg.Msg.GetMessageName(), msg.Msg.GetCrcString())
+ buf := new(bytes.Buffer)
+ context := clientID
+ if msg.hasCtx {
+ context = setMultipart(context, msg.Multipart)
+ context = setSeqNum(context, msg.SeqNum)
+ }
+ if msg.Msg.GetMessageType() == api.ReplyMessage {
+ struc.Pack(buf, &codec.VppReplyHeader{VlMsgID: msgID, Context: context})
+ } else if msg.Msg.GetMessageType() == api.RequestMessage {
+ struc.Pack(buf, &codec.VppRequestHeader{VlMsgID: msgID, Context: context})
+ } else if msg.Msg.GetMessageType() == api.EventMessage {
+ struc.Pack(buf, &codec.VppEventHeader{VlMsgID: msgID})
+ } else {
+ struc.Pack(buf, &codec.VppOtherHeader{VlMsgID: msgID})
+ }
+ struc.Pack(buf, msg.Msg)
+ a.callback(msgID, buf.Bytes())