MCPcopy Create free account
hub / github.com/SeeFlowerX/stackplz / handleConnection

Function handleConnection

user/rpc/rpc.go:145–185  ·  view source on GitHub ↗
(conn net.Conn)

Source from the content-addressed store, hash-verified

143}
144
145func handleConnection(conn net.Conn) {
146 defer conn.Close()
147
148 for {
149 var size uint32 = 0
150 err := binary.Read(conn, binary.LittleEndian, &size)
151 if err != nil {
152 return
153 }
154
155 buffer := make([]byte, size)
156 err = binary.Read(conn, binary.LittleEndian, &buffer)
157 if err != nil {
158 return
159 }
160
161 msg := RespMsg{}
162
163 brk_options, err := ParseMsg(buffer)
164 if err != nil {
165 msg.Status = "error"
166 msg.Msg = fmt.Sprintf("ParseMsg failed, err:%v", err)
167 } else {
168 Logger.Println("Received message:", string(buffer))
169 BrkIt(brk_options)
170 msg.Status = "ok"
171 msg.Msg = "register breakpoint success"
172 }
173
174 resp, err := json.Marshal(msg)
175 err = binary.Write(conn, binary.LittleEndian, uint32(len(resp)))
176 if err != nil {
177 return
178 }
179 err = binary.Write(conn, binary.LittleEndian, resp)
180 if err != nil {
181 return
182 }
183 Logger.Println("resp ->", string(resp))
184 }
185}

Callers 1

StartRpcServerFunction · 0.85

Calls 4

ParseMsgFunction · 0.85
BrkItFunction · 0.85
CloseMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected