user_chat.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package gatesink
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "bet24.com/log"
  6. "bet24.com/servers/coreservice/client"
  7. "bet24.com/servers/fishhall/protocol"
  8. "bet24.com/servers/insecureframe/gate"
  9. )
  10. // 世界聊天
  11. func (this *user) sendChatMsg(msg, data string) {
  12. var req protocol.Chat_req
  13. if err := json.Unmarshal([]byte(data), &req); err != nil {
  14. retData := fmt.Sprintf("chat_req Unmarshal data failed %v", data)
  15. log.Release(retData)
  16. this.WriteMsg(msg, retData)
  17. return
  18. }
  19. u := gate.GetUserInfo(this.UserIndex)
  20. if u == nil {
  21. return
  22. }
  23. //聊天不需要返回, 信息推送显示
  24. if !client.SendChatMsg(req.ChannelID, u.GetUserId(), u.GetUserFaceId(), u.GetUserSex(), u.GetUserVipLevel(),
  25. req.RecvUserID, u.GetUserNickName(), u.GetUserFaceUrl(), req.Msg, this.GetIP(), req.MsgType, u.GetUserVipExpire()) {
  26. this.WriteMsg(msg, "sendChatMsg failed")
  27. }
  28. }
  29. func (this *user) getChatMsg(msg, data string) {
  30. var req protocol.Chat_req
  31. if err := json.Unmarshal([]byte(data), &req); err != nil {
  32. retData := fmt.Sprintf("chat_req Unmarshal data failed %v", data)
  33. log.Release(retData)
  34. this.WriteMsg(msg, retData)
  35. return
  36. }
  37. u := gate.GetUserInfo(this.UserIndex)
  38. if u == nil {
  39. return
  40. }
  41. this.WriteMsg(msg, client.GetChatMsg(u.GetUserId(), req.ChannelID))
  42. }
  43. func (this *user) sendChannelChat(msg, data string) {
  44. var req protocol.Chat_req
  45. if err := json.Unmarshal([]byte(data), &req); err != nil {
  46. retData := fmt.Sprintf("chat_req Unmarshal data failed %v", data)
  47. log.Release(retData)
  48. this.WriteMsg(msg, retData)
  49. return
  50. }
  51. u := gate.GetUserInfo(this.UserIndex)
  52. if u == nil {
  53. return
  54. }
  55. ret := client.SendChannelChat(u.GetUserId(), req.RecvUserID, req.Msg, req.MsgType)
  56. if ret == "failed" || ret == "" {
  57. this.WriteMsg(msg, ret)
  58. } else {
  59. this.WriteMsg("getChannelChat", ret)
  60. }
  61. }
  62. func (this *user) getChannelChat(msg, data string) {
  63. u := gate.GetUserInfo(this.UserIndex)
  64. if u == nil {
  65. return
  66. }
  67. ret := client.GetChannelChat(data, u.GetUserId())
  68. this.WriteMsg("getChannelChat", ret)
  69. }
  70. func (this *user) getChannelInfo(msg, data string) {
  71. u := gate.GetUserInfo(this.UserIndex)
  72. if u == nil {
  73. return
  74. }
  75. ret := client.GetChannelInfo(data)
  76. this.WriteMsg("getChannelInfo", ret)
  77. }
  78. func (this *user) clearChannelHistory(msg, data string) {
  79. client.ClearChannelHistory(data, this.getUserId())
  80. }