MCPcopy
hub / github.com/TarsCloud/TarsGo / ReportMicMsgWithContext

Method ReportMicMsgWithContext

tars/protocol/res/statf/StatF.tars.go:75–152  ·  view source on GitHub ↗

ReportMicMsgWithContext is the proxy function for the method defined in the tars file, with the context

(tarsCtx context.Context, msg map[StatMicMsgHead]StatMicMsgBody, bFromClient bool, opts ...map[string]string)

Source from the content-addressed store, hash-verified

73
74// ReportMicMsgWithContext is the proxy function for the method defined in the tars file, with the context
75func (obj *StatF) ReportMicMsgWithContext(tarsCtx context.Context, msg map[StatMicMsgHead]StatMicMsgBody, bFromClient bool, opts ...map[string]string) (ret int32, err error) {
76 var (
77 length int32
78 have bool
79 ty byte
80 )
81 buf := codec.NewBuffer()
82 err = buf.WriteHead(codec.MAP, 1)
83 if err != nil {
84 return ret, err
85 }
86 err = buf.WriteInt32(int32(len(msg)), 0)
87 if err != nil {
88 return ret, err
89 }
90 for k0, v0 := range msg {
91 err = k0.WriteBlock(buf, 0)
92 if err != nil {
93 return ret, err
94 }
95 err = v0.WriteBlock(buf, 1)
96 if err != nil {
97 return ret, err
98 }
99 }
100
101 err = buf.WriteBool(bFromClient, 2)
102 if err != nil {
103 return ret, err
104 }
105
106 var statusMap map[string]string
107 var contextMap map[string]string
108 if len(opts) == 1 {
109 contextMap = opts[0]
110 } else if len(opts) == 2 {
111 contextMap = opts[0]
112 statusMap = opts[1]
113 }
114
115 tarsResp := new(requestf.ResponsePacket)
116 err = obj.servant.TarsInvoke(tarsCtx, 0, "reportMicMsg", buf.ToBytes(), statusMap, contextMap, tarsResp)
117 if err != nil {
118 return ret, err
119 }
120 readBuf := codec.NewReader(tools.Int8ToByte(tarsResp.SBuffer))
121 err = readBuf.ReadInt32(&ret, 0, true)
122 if err != nil {
123 return ret, err
124 }
125
126 if len(opts) == 1 {
127 for k := range contextMap {
128 delete(contextMap, k)
129 }
130 for k, v := range tarsResp.Context {
131 contextMap[k] = v
132 }

Callers 1

ReportMicMsgMethod · 0.95

Calls 10

WriteHeadMethod · 0.95
WriteInt32Method · 0.95
WriteBoolMethod · 0.95
ToBytesMethod · 0.95
ReadInt32Method · 0.95
NewBufferFunction · 0.92
NewReaderFunction · 0.92
Int8ToByteFunction · 0.92
WriteBlockMethod · 0.65
TarsInvokeMethod · 0.65

Tested by

no test coverage detected