handler_from_player_msg.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package handler
  2. import (
  3. "call_center/call/rpc/internal/core"
  4. "call_center/call/rpc/internal/interaction"
  5. "call_center/call/rpc/pb"
  6. "errors"
  7. )
  8. func FromPlayerMsg(interDb interaction.InterDb, server *core.Server, streamId string, msg *pb.CommandMsg) error {
  9. chatMsg := msg.GetChatMsg()
  10. player := server.GetPlayer(streamId)
  11. input := chatMsg.Input
  12. player.RefreshTalkTimeStamp() // 刷新发言时间
  13. // 接收数据
  14. // gid := common.GetGoroutineID()
  15. // log.Printf("[gid: %v][收到消息]: %s from: %v \n", gid, input, streamId)
  16. service := server.GetServiceByPlayerId(streamId)
  17. if service != nil {
  18. // 人工接听时, 消息返回给客服
  19. err := server.MsgToService(service.Stream, input, streamId)
  20. if err != nil {
  21. return err
  22. }
  23. interDb.ChatLogToDb(player, streamId, service.Id, input, true)
  24. // err = server.MsgToClient(stream, "success")
  25. } else {
  26. return errors.New("<FromPlayerMsg> 客服不存在")
  27. //// 机器自动回复
  28. //robotMsg := "[robot回复]" + input
  29. //err := server.MsgToClient(stream, robotMsg)
  30. //// interaction.DbInst.ChatLogToDb(streamId, "", input, true)
  31. //
  32. //if err != nil {
  33. // return err
  34. //}
  35. }
  36. return nil
  37. }