user_friend.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. )
  9. // 搜索玩家(兼容旧接口协议)
  10. func (this *user) getSearchUserinfo(msg, data string) {
  11. var req protocol.Friend_req
  12. if err := json.Unmarshal([]byte(data), &req); err != nil {
  13. retData := fmt.Sprintf("getSearchUserinfo Unmarshal data failed %v", data)
  14. log.Release(retData)
  15. this.WriteMsg(msg, retData)
  16. return
  17. }
  18. resp := client.GetSearchUserinfo(this.getUserId(), req.TargetUserID, req.TargetNickName)
  19. if resp.RetCode != 1 {
  20. log.Debug("user.getSearchUserinfo failed %v", resp)
  21. }
  22. this.WriteMsg(msg, resp.Data)
  23. }
  24. // 搜索玩家列表
  25. func (this *user) getSearchUserList(msg, data string) {
  26. var req protocol.Friend_req
  27. if err := json.Unmarshal([]byte(data), &req); err != nil {
  28. retData := fmt.Sprintf("getSearchUserList Unmarshal data failed %v", data)
  29. log.Release(retData)
  30. this.WriteMsg(msg, retData)
  31. return
  32. }
  33. resp := client.GetSearchUserList(this.getUserId(), req.TargetUserID, req.TargetNickName)
  34. if resp.RetCode != 1 {
  35. log.Debug("user.getSearchUserList failed %v", resp)
  36. }
  37. this.WriteMsg(msg, resp.Data)
  38. }
  39. // 获取好友列表
  40. func (this *user) getFriendList(msg, data string) {
  41. resp := client.GetFriendList(this.getUserId())
  42. if resp.RetCode != 1 {
  43. log.Debug("user.GetFriendList failed %v", resp)
  44. }
  45. this.WriteMsg(msg, resp.Data)
  46. }
  47. // 好友审核列表
  48. func (this *user) friendVerifyList(msg, data string) {
  49. resp := client.FriendVerifyList(this.getUserId())
  50. if resp.RetCode != 1 {
  51. log.Debug("user.friendVerifyList failed %v", resp)
  52. }
  53. this.WriteMsg(msg, resp.Data)
  54. }
  55. // 添加好友
  56. func (this *user) friendApply(msg, data string) {
  57. var req protocol.Friend_req
  58. if err := json.Unmarshal([]byte(data), &req); err != nil {
  59. retData := fmt.Sprintf("Friend_req Unmarshal data failed %v", data)
  60. log.Release(retData)
  61. this.WriteMsg(msg, retData)
  62. return
  63. }
  64. resp := client.FriendApply(this.getUserId(), req.TargetUserID)
  65. if resp.RetCode != 1 {
  66. log.Debug("user.friendApply failed %v", resp)
  67. }
  68. this.WriteMsg(msg, resp.Data)
  69. }
  70. // 删除好友
  71. func (this *user) delFriend(msg, data string) {
  72. var req protocol.Friend_req
  73. if err := json.Unmarshal([]byte(data), &req); err != nil {
  74. retData := fmt.Sprintf("Friend_req Unmarshal data failed %v", data)
  75. log.Release(retData)
  76. this.WriteMsg(msg, retData)
  77. return
  78. }
  79. resp := client.DelFriend(this.getUserId(), req.TargetUserID)
  80. if resp.RetCode != 1 {
  81. log.Debug("user.DelFriend failed %v", resp)
  82. }
  83. this.WriteMsg(msg, resp.Data)
  84. }
  85. // 好友申请处理
  86. func (this *user) friendHandleApply(msg, data string) {
  87. var req protocol.Friend_HandleApply_req
  88. if err := json.Unmarshal([]byte(data), &req); err != nil {
  89. retData := fmt.Sprintf("Friend_HandleApply_req Unmarshal data failed %v", data)
  90. log.Release(retData)
  91. this.WriteMsg(msg, retData)
  92. return
  93. }
  94. resp := client.FriendHandleApply(this.getUserId(), req.TargetUserID, req.Apply)
  95. if resp.RetCode != 1 {
  96. log.Debug("user.FriendHandleApply failed %v", resp)
  97. }
  98. this.WriteMsg(msg, resp.Data)
  99. }
  100. // 赠送礼物
  101. func (this *user) friendGiveGift(msg, data string) {
  102. var req protocol.Friend_req
  103. if err := json.Unmarshal([]byte(data), &req); err != nil {
  104. retData := fmt.Sprintf("Friend_req Unmarshal data failed %v", data)
  105. log.Release(retData)
  106. this.WriteMsg(msg, retData)
  107. return
  108. }
  109. resp := client.FriendGiveGift(this.getUserId(), req.TargetUserID)
  110. if resp.RetCode != 1 {
  111. log.Debug("user.friendGiveGift failed %v", resp)
  112. }
  113. this.WriteMsg(msg, resp.Data)
  114. }
  115. // 获得礼物
  116. func (this *user) friendGetGift(msg, data string) {
  117. var req protocol.Friend_req
  118. if err := json.Unmarshal([]byte(data), &req); err != nil {
  119. retData := fmt.Sprintf("Friend_req Unmarshal data failed %v", data)
  120. log.Release(retData)
  121. this.WriteMsg(msg, retData)
  122. return
  123. }
  124. resp := client.FriendGetGift(this.getUserId(), req.TargetUserID, this.GetIP())
  125. if resp.RetCode != 1 {
  126. log.Debug("user.friendGetGift failed %v", resp)
  127. }
  128. this.WriteMsg(msg, resp.Data)
  129. }
  130. func (this *user) friendRoomInvite(msg, data string) {
  131. var req protocol.FriendRoomInvite_req
  132. if err := json.Unmarshal([]byte(data), &req); err != nil {
  133. retData := fmt.Sprintf("user.friendRoomInvite unmarshal data fail %v", err)
  134. log.Release(retData)
  135. this.WriteMsg(msg, retData)
  136. return
  137. }
  138. client.FriendRoomInvite(this.getUserId(), this.getNickName(), req.ToUserId, req.RoomNo)
  139. this.WriteMsg(msg, "")
  140. }
  141. func (this *user) friendGetRoomInviteList(msg, data string) {
  142. resp := client.FriendGetRoomInviteList(this.getUserId())
  143. if resp.RetCode != 1 {
  144. log.Debug("user.friendGetRoomInviteList failed %v", resp)
  145. }
  146. this.WriteMsg(msg, resp.Data)
  147. }
  148. func (this *user) friendRoomInviteInvalid(msg, data string) {
  149. var req protocol.FriendRoomInvite_req
  150. if err := json.Unmarshal([]byte(data), &req); err != nil {
  151. retData := fmt.Sprintf("user.friendRoomInviteInvalid unmarshal data fail %v", err)
  152. log.Release(retData)
  153. this.WriteMsg(msg, retData)
  154. return
  155. }
  156. client.FriendRoomInviteInvalid(this.getUserId(), req.RoomNo)
  157. this.WriteMsg(msg, "")
  158. }
  159. func (this *user) getMaxFriendCount(msg string) {
  160. resp := client.GetMaxFriendCount(this.getUserId())
  161. this.WriteMsg(msg, resp.Data)
  162. }
  163. func (this *user) getPotentialFriendList(msg string) {
  164. this.WriteMsg(msg, client.FriendGetPotentialList(this.getUserId()))
  165. }
  166. // 黑名单列表
  167. func (this *user) friendGetBlackList(msg, data string) {
  168. var req protocol.FriendBlack_req
  169. if err := json.Unmarshal([]byte(data), &req); err != nil {
  170. retData := fmt.Sprintf("user.friendGetBlackList unmarshal data fail %v", err)
  171. log.Release(retData)
  172. this.WriteMsg(msg, retData)
  173. return
  174. }
  175. jsonData := client.FriendGetBlackList(this.getUserId(), req.PageIndex, req.PageSize)
  176. this.WriteMsg(msg, jsonData)
  177. return
  178. }
  179. // 添加黑名单
  180. func (this *user) friendAddBlack(msg, data string) {
  181. var req protocol.FriendBlack_req
  182. if err := json.Unmarshal([]byte(data), &req); err != nil {
  183. retData := fmt.Sprintf("user.friendAddBlack unmarshal data fail %v", err)
  184. log.Release(retData)
  185. this.WriteMsg(msg, retData)
  186. return
  187. }
  188. rsp := client.FriendAddBlack(this.getUserId(), req.ToUserId)
  189. this.WriteMsg(msg, rsp.Data)
  190. return
  191. }
  192. // 删除黑名单
  193. func (this *user) friendDelBlack(msg, data string) {
  194. var req protocol.FriendBlack_req
  195. if err := json.Unmarshal([]byte(data), &req); err != nil {
  196. retData := fmt.Sprintf("user.friendDelBlack unmarshal data fail %v", err)
  197. log.Release(retData)
  198. this.WriteMsg(msg, retData)
  199. return
  200. }
  201. rsp := client.FriendDelBlack(this.getUserId(), req.ToUserId)
  202. this.WriteMsg(msg, rsp.Data)
  203. return
  204. }