MCPcopy Index your code
hub / github.com/dearcode/candy / newMessage

Function newMessage

candy.go:257–291  ·  view source on GitHub ↗
(c *candy.CandyClient, reader *bufio.Reader)

Source from the content-addressed store, hash-verified

255 log.Debugf("confirmFriend userID:%v", userID)
256}
257func newMessage(c *candy.CandyClient, reader *bufio.Reader) {
258 fmt.Println("----------------发送消息-----------------------")
259 defer endSection()
260 id := int64(0)
261
262 fmt.Println("请输入接收用户ID:")
263 data, _, _ := reader.ReadLine()
264 userID := string(data)
265
266 user, err := strconv.ParseInt(userID, 10, 64)
267 if err != nil {
268 e := candy.ErrorParse(err.Error())
269 log.Errorf("Parse int code:%v error:%v", e.Code, e.Msg)
270 return
271 }
272
273 for {
274 fmt.Println("请输入消息内容(quit退出):")
275 data, _, _ = reader.ReadLine()
276 msg := string(data)
277
278 if msg == "quit" {
279 break
280 }
281
282 id, err = c.SendMessage(0, user, msg)
283 if err != nil {
284 e := candy.ErrorParse(err.Error())
285 log.Errorf("send message code:%v error:%v", e.Code, e.Msg)
286 return
287 }
288
289 log.Debugf("send msg[%d] success, userID:%v", id, userID)
290 }
291}
292
293func createGroup(c *candy.CandyClient, reader *bufio.Reader) {
294 fmt.Println("----------------创建群组-----------------------")

Callers 1

mainFunction · 0.85

Calls 3

endSectionFunction · 0.85
SendMessageMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected