gameframesync.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. package msg
  2. import (
  3. "encoding/json"
  4. )
  5. // Entry 登录
  6. type GameSyncEntry struct {
  7. PlayerId int64 `json:"userId"`
  8. Token string `json:"token"`
  9. LineId int `json:"serverId"`
  10. SyncRoomId int64 `json:"syncRoomId,string"`
  11. ReLogin int32 `json:"reLogin"` // 重连1
  12. }
  13. type ResponseGameSyncEntry struct {
  14. ErrCode int `json:"errCode"`
  15. Msg string `json:"msg,omitempty"`
  16. Data int `json:"data"`
  17. }
  18. type GameSyncHeartBeat struct {
  19. PlayerId int64 `json:"userId"`
  20. }
  21. type ResponseGameSyncHeartBeat struct {
  22. ErrCode int `json:"errCode"`
  23. Msg string `json:"msg,omitempty"`
  24. Data int64 `json:"data"`
  25. }
  26. // Entry 重连
  27. type GameSyncReLogin struct {
  28. PlayerId int64 `json:"userId"`
  29. }
  30. // Entry 重连
  31. type GameSynToken struct {
  32. PlayerId int64 `json:"userId"`
  33. }
  34. type GameJoinerAttr struct {
  35. PlayerId int64 `json:"userId"`
  36. }
  37. // 创建帧同步房间
  38. type CreateGameFrameSyncGroupIs struct {
  39. RpcRequestMsg
  40. SyncRoomId int64 `json:"SyncRoomId,string"`
  41. Token string `json:"token"`
  42. Joiners []*JoinerAttr `json:"joiners"`
  43. }
  44. type ResponseCreateGameSyncRoomIs struct {
  45. RpcResponseMsg
  46. }
  47. type GameFrameSyncToServer struct {
  48. PlayerId int64 `json:"userId"`
  49. SyncRoomId int64 `json:"syncRoomId,string"`
  50. RawData []json.RawMessage `json:"raw,omitempty"` // 客户端某一个行为的数据
  51. // FrameId int64 `json:"frameId"`
  52. }
  53. // 客户端上报章节同步已准备好
  54. type GameSyncReady struct {
  55. PlayerId int64 `json:"userId"`
  56. SyncRoomId int64 `json:"syncRoomId,string"`
  57. }
  58. type ResponseGameSyncReady struct {
  59. ErrCode int `json:"errCode"`
  60. Msg string `json:"msg,omitempty"`
  61. Data int `json:"data,string"`
  62. }
  63. type GameSyncCache struct {
  64. PlayerId int64 `json:"userId"`
  65. SyncRoomId int64 `json:"syncRoomId,string"`
  66. SyncCacheId int64 `json:"syncCacheId"` // 缓存快照id
  67. SyncCache json.RawMessage `json:"syncCache,omitempty"` // 缓存快照
  68. }
  69. type ResponseGameSyncCache struct {
  70. ErrCode int `json:"errCode"`
  71. Msg string `json:"msg,omitempty"`
  72. Data int `json:"data,string"`
  73. }
  74. // 服务端通知开始章节同步
  75. type GameSyncStart struct {
  76. ErrCode int `json:"errCode"`
  77. Msg string `json:"msg,omitempty"`
  78. Data int64 `json:"data,string"` //syncroomid
  79. }
  80. type GameSyncSettle struct {
  81. PlayerId int64 `json:"userId"`
  82. SyncRoomId int64 `json:"syncRoomId,string"`
  83. Id int64 `json:"id"`
  84. Wave int64 `json:"wave"`
  85. Rewards int64 `json:"rewards"` // 多倍奖励原因 0:无多倍奖励;1:广告
  86. Score int64 `json:"score"` // 积分
  87. Data json.RawMessage `json:"log,omitempty"`
  88. }
  89. type GameSyncSettleIs struct {
  90. PublishMsg
  91. PlayerId int64 `json:"userId"`
  92. SyncRoomId int64 `json:"syncRoomId,string"`
  93. Id int64 `json:"id"`
  94. Wave int64 `json:"wave"`
  95. Rewards int64 `json:"rewards"` // 多倍奖励原因 0:无多倍奖励;1:广告
  96. FriendId int64 `json:"friendId"` // 好友id 以下服务端填充用
  97. Score int64 `json:"score"` // 积分
  98. Data json.RawMessage `json:"log,omitempty"` // 战斗日志
  99. }
  100. type GameSyncDisconnectRoomIs struct {
  101. PublishMsg
  102. PlayerId int64 `json:"userId"`
  103. }
  104. // 房间结算
  105. type ResponseGameSyncSettle struct {
  106. ErrCode int `json:"errCode"`
  107. Msg string `json:"msg,omitempty"`
  108. Data int64 `json:"data"` //syncroomid
  109. }
  110. type GameFrameSyncInfo struct {
  111. PlayerId int64 `json:"userId"`
  112. SyncRoomId int64 `json:"syncRoomId,string"`
  113. FrameId int64 `json:"frameId"` // 起始帧号
  114. }
  115. type GameFrameSyncInfoData struct {
  116. FrameId int64 `json:"maxFrameId"` // 当前最大帧号
  117. Data map[int64][]json.RawMessage `json:"raw,omitempty"` // 帧数据
  118. SyncCacheId int64 `json:"syncCacheId"` // 缓存快照id
  119. SyncCache json.RawMessage `json:"syncCache,omitempty"` // 缓存快照
  120. }
  121. type ResponseGameFrameSyncInfo struct {
  122. ErrCode int `json:"errCode"`
  123. Msg string `json:"msg,omitempty"`
  124. Data *GameFrameSyncInfoData `json:"data"`
  125. }
  126. // 数据到服务器
  127. type GameSyncToServer struct {
  128. PlayerId int64 `json:"userId"`
  129. SyncRoomId int64 `json:"syncRoomId,string"`
  130. RawData json.RawMessage `json:"raw,omitempty"`
  131. }
  132. // 数据到客户端
  133. type GameSyncToClient struct {
  134. ErrCode int `json:"errCode"`
  135. Msg string `json:"msg,omitempty"`
  136. Data GameSyncToClientData `json:"data"`
  137. }
  138. type GameSyncToClientData struct {
  139. FrameId int64 `json:"id"`
  140. SyncCacheFlag bool `json:"syncCacheFlag"` // true 代表当前帧号为同步缓存帧号
  141. Datas []json.RawMessage `json:"raws"`
  142. }
  143. type GameSyncChat struct {
  144. PlayerId int64 `json:"userId"`
  145. SyncRoomId int64 `json:"syncRoomId,string"`
  146. // Chat json.RawMessage `json:"chat,omitempty"` // 聊天内容
  147. Chat *GameSyncChatData `json:"sendChatInfo"` //新聊天信息
  148. }
  149. type GameSyncChatData struct {
  150. SenderId int64 `json:"senderId"`
  151. MsgType string `json:"msgType"` // text:文本 emoji:表情
  152. Content string `json:"content"` // 聊天内容
  153. }
  154. type ResponseGameSyncChat struct {
  155. ErrCode int `json:"errCode"`
  156. Msg string `json:"msg,omitempty"`
  157. Data *GameSyncChatData `json:"data"` //新聊天信息
  158. }