MOHttpManager+Line+PK.swift 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // MOHttpManager.swift
  3. // MiMoLive
  4. //
  5. // Created by OneeChan on 2025/9/28.
  6. //
  7. import Foundation
  8. // MARK: =========== About PK V2 ============
  9. //PK-连线-结算
  10. let kNetPath_Code_PkV2Settle = "/live/pk/v2/settlement"
  11. //PK-连线-查询pk-连线房间信息
  12. let kNetPath_Code_PkV2RoomInfo = "/live/pk/v2/room/info"
  13. //PK-连线 - 匹配
  14. let kNetPath_Code_PkV2Match = "/live/pk/v2/match"
  15. //PK-连线-连线转PK
  16. let kNetPath_Code_PkV2LinkToPk = "/live/pk/v2/link_to_pk"
  17. //PK-连线-设置
  18. let kNetPath_Code_PkV2ConfigSet = "/live/pk/v2/link/config/set"
  19. //PK-连线-设置查询
  20. let kNetPath_Code_PkV2ConfigGet = "/live/pk/v2/link/config/get"
  21. //PK-连线-关闭连线-入参:pk连线房间id
  22. let kNetPath_Code_PkV2LinkClose = "/live/pk/v2/link/close"
  23. //PK-连线-邀请 - 发送邀请-参数是房间id
  24. let kNetPath_Code_PkV2InviteSend = "/live/pk/v2/invite/send"
  25. //PK-连线-邀请 - 列表
  26. let kNetPath_Code_PkV2InviteList = "/live/pk/v2/invite/list"
  27. //PK-连线-邀请 - 处理邀请
  28. let kNetPath_Code_PkV2InviteHandler = "/live/pk/v2/invite/handler"
  29. //PK-连线 - PK贡献榜
  30. let kNetPath_Code_PKV2Contribute = "/live/pk/v2/contribute"
  31. //PK-连线 - PK历史记录
  32. let kNetPath_Code_PKV2History = "/live/pk/v2/record"
  33. // PK-连线-清理连线数值
  34. let kNetPath_PkV2ClearBean = "/live/pk/v2/link/clean/value"
  35. // PK-连线- 连线中房主设置
  36. let kNetPath_PkV2SetLineConfig = "/live/pk/v2/link/ing/set"
  37. // PK-连线-关闭pk-投降
  38. let kNetPath_PkV2Surrender = "/live/pk/v2/surrender"
  39. // PK-连线 - 声音控制
  40. let kNetPath_PkV2SoundControl = "/live/pk/v2/sound/control"
  41. // MARK: About PK V2
  42. extension MOHttpManager {
  43. /// PK-连线-查询pk-连线房间信息
  44. /// - Parameters:
  45. /// - params: 参数
  46. /// - block: 回调
  47. func getLineRoomInfo(_ roomId: String, handler: @escaping (MOLivePkLinkRoomInfoVo?, String?) -> Void) {
  48. sendPostRequest(path: kNetPath_Code_PkV2RoomInfo, params: ["id": roomId], handler: handler)
  49. }
  50. /// PK-连线 - 匹配
  51. /// - Parameters:
  52. /// - params: 参数
  53. /// - block: 回调
  54. func matchLine(_ roomId: String, _ lineType: LineType, handler: @escaping (String?) -> Void) {
  55. sendPostRequest(path: kNetPath_Code_PkV2Match, params: ["roomId": roomId, "matchType": lineType.rawValue, "cancel": false], handler: handler)
  56. }
  57. func cancelMatch(_ roomId: String, _ lineType: LineType, handler: @escaping (String?) -> Void) {
  58. sendPostRequest(path: kNetPath_Code_PkV2Match, params: ["roomId": roomId, "matchType": lineType.rawValue, "cancel": true], handler: handler)
  59. }
  60. /// PK-连线-连线转PK
  61. /// - Parameters:
  62. /// - params: 参数
  63. /// - block: 回调
  64. func startPk(_ lineRoomId: String, handler: @escaping (String?) -> Void) {
  65. sendPostRequest(path: kNetPath_Code_PkV2LinkToPk, params: ["id": lineRoomId], handler: handler)
  66. }
  67. /// PK-连线-设置查询
  68. /// - Parameters:
  69. /// - params: 参数
  70. /// - block: 回调
  71. func getLinePkConfig(handler: @escaping (MOLivePkLinkConfigVo?, String?) -> Void) {
  72. sendPostRequest(path: kNetPath_Code_PkV2ConfigGet, params: [:], handler: handler)
  73. }
  74. /// PK-连线-设置
  75. /// - Parameters:
  76. /// - params: 参数
  77. /// - block: 回调
  78. func updateLinePkConfig(duration: Int, canAcceptPk: Bool,
  79. magnifyMySelf: Bool, canAcceptLink: Bool,
  80. handler: @escaping (String?) -> Void) {
  81. sendPostRequest(path: kNetPath_Code_PkV2ConfigSet,
  82. params: [
  83. "duration": duration,
  84. "canAcceptPk": canAcceptPk,
  85. "magnifyMySelf": magnifyMySelf,
  86. "canAcceptLink": canAcceptLink
  87. ],
  88. handler: handler)
  89. }
  90. /// PK-连线-关闭连线-入参:pk连线房间id
  91. /// - Parameters:
  92. /// - params: 参数
  93. /// - block: 回调
  94. func closeLine(_ lineRoomId: String, handler: @escaping (String?) -> Void) {
  95. sendPostRequest(path: kNetPath_Code_PkV2LinkClose, params: ["id": lineRoomId], handler: handler)
  96. }
  97. /// PK-连线-邀请 - 发送邀请-参数是房间id
  98. /// - Parameters:
  99. /// - params: 参数
  100. /// - block: 回调
  101. func inviteLine(_ roomId: String, _ peerRoomId: String, _ lineType: LineType, handler: @escaping (String?) -> Void) {
  102. sendPostRequest(path: kNetPath_Code_PkV2InviteSend, params: ["roomId": roomId, "toRoomId": peerRoomId, "type": lineType.rawValue], handler: handler)
  103. }
  104. /// PK-连线-邀请 - 列表
  105. func getLineInviteList(next: String, size: Int, searchKey: String,
  106. handler: @escaping (MONextVOLivePkLinkInviteVO?, String?) -> Void) {
  107. sendPostRequest(path: kNetPath_Code_PkV2InviteList,
  108. params: ["type": 2, "searchKey": searchKey, "page": ["next": next, "size": size]],
  109. handler: handler)
  110. }
  111. func getLinePkInviteList(next: String, size: Int, searchKey: String,
  112. handler: @escaping (MONextVOLivePkLinkInviteVO?, String?) -> Void) {
  113. sendPostRequest(path: kNetPath_Code_PkV2InviteList,
  114. params: ["type": 1, "searchKey": searchKey, "page": ["next": next, "size": size]],
  115. handler: handler)
  116. }
  117. /// PK-连线-邀请 - 处理邀请
  118. /// - Parameters:
  119. /// - params: 参数
  120. /// - block: 回调
  121. func responseLineInvite(_ inviteId: String, _ accept: Bool, handler: @escaping (String?) -> Void) {
  122. sendPostRequest(path: kNetPath_Code_PkV2InviteHandler, params: ["inviteId": inviteId, "agree": accept], handler: handler)
  123. }
  124. /// PK-连线-PK贡献榜
  125. func getLinePkContributeList(_ campCode: String, _ next: String, _ size: Int, handler: @escaping (MOLivePkContributeVO?, String?) -> Void) {
  126. sendPostRequest(path: kNetPath_Code_PKV2Contribute,
  127. params: ["campCode": campCode, "page": ["next": next, "size": size]],
  128. handler: handler)
  129. }
  130. /// PK-连线-结算
  131. /// - Parameters:
  132. /// - params: 参数
  133. /// - block: 回调
  134. func settlePk(_ linkRoomId: String, _ pkMatchId: String, handler: @escaping (MORtmPkV2Status?, String?) -> Void) {
  135. sendPostRequest(path: kNetPath_Code_PkV2Settle, params: ["pkLinkRoomId": linkRoomId, "pkMatchId": pkMatchId], handler: handler)
  136. }
  137. /// PK-连线- PK历史记录
  138. func getLinePkHistory(historyType: LinePkHistoryType, next: String, size: Int, handler: @escaping (MONextVOLivePkV2RecordVo?, String?) -> Void) {
  139. sendPostRequest(path: kNetPath_Code_PKV2History,
  140. params: ["type": historyType.rawValue, "page": ["next": next, "size": size]],
  141. handler: handler)
  142. }
  143. /// PK-连线-清理连线数值
  144. func cleanLineRoomBeans(_ linkRoomId: String, handler: @escaping (String?) -> Void) {
  145. sendPostRequest(path: kNetPath_PkV2ClearBean, params: ["id": linkRoomId], handler: handler)
  146. }
  147. /// PK-连线- 连线中房主设置
  148. func updateLineRoomConfig(_ lineRoomId: String, showValue: Bool,
  149. allowJoin: Bool, allowInvite: Bool,
  150. handler: @escaping (String?) -> Void) {
  151. sendPostRequest(path: kNetPath_PkV2SetLineConfig,
  152. params: [
  153. "pkLinkRoomId": lineRoomId,
  154. "showValue": showValue,
  155. "allowJoin": allowJoin,
  156. "allowInvite": allowInvite
  157. ],
  158. handler: handler)
  159. }
  160. /// PK-连线-关闭pk-投降
  161. func surrenderPk(_ pkMatchId: String, handler: @escaping (String?) -> Void) {
  162. sendPostRequest(path: kNetPath_PkV2Surrender, params: ["id": pkMatchId], handler: handler)
  163. }
  164. /// PK-连线 - 声音控制
  165. func updateSoundControl(_ lineRoomId: String, userIds: [String], mute: Bool, forAll: Bool, handler: @escaping (String?) -> Void) {
  166. sendPostRequest(path: kNetPath_PkV2SoundControl,
  167. params: [
  168. "pkLinkRoomId": lineRoomId,
  169. "userIds": userIds,
  170. "mute": mute,
  171. "forAll": forAll
  172. ],
  173. handler: handler)
  174. }
  175. }