@ughuuu/game_server 1.0.1001 → 1.0.1004

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +24 -24
  2. package/dist/ApiClient.js +1 -1
  3. package/dist/api/AchievementsApi.js +15 -15
  4. package/dist/api/AdminAchievementsApi.js +16 -16
  5. package/dist/api/AdminChatApi.js +6 -6
  6. package/dist/api/AdminGroupsApi.js +2 -2
  7. package/dist/api/AdminKVApi.js +19 -19
  8. package/dist/api/AdminLeaderboardsApi.js +19 -19
  9. package/dist/api/AdminLobbiesApi.js +2 -2
  10. package/dist/api/AdminNotificationsApi.js +2 -2
  11. package/dist/api/AdminSessionsApi.js +2 -2
  12. package/dist/api/AdminUsersApi.js +2 -2
  13. package/dist/api/AuthenticationApi.js +2 -2
  14. package/dist/api/ChatApi.js +11 -11
  15. package/dist/api/FriendsApi.js +7 -7
  16. package/dist/api/GroupsApi.js +41 -41
  17. package/dist/api/HealthApi.js +1 -1
  18. package/dist/api/HooksApi.js +2 -2
  19. package/dist/api/KVApi.js +2 -2
  20. package/dist/api/LeaderboardsApi.js +6 -6
  21. package/dist/api/LobbiesApi.js +6 -6
  22. package/dist/api/NotificationsApi.js +6 -6
  23. package/dist/api/PartiesApi.js +25 -25
  24. package/dist/api/PaymentsApi.js +2 -2
  25. package/dist/api/UsersApi.js +3 -3
  26. package/dist/index.js +133 -133
  27. package/dist/model/{ShowParty200Response.js → AcceptPartyInvite200Response.js} +27 -27
  28. package/dist/model/{ShowParty200ResponseMembersInner.js → AcceptPartyInvite200ResponseMembersInner.js} +23 -23
  29. package/dist/model/AcceptPartyInviteRequest.js +1 -1
  30. package/dist/model/AdminCreateAchievementRequest.js +1 -1
  31. package/dist/model/{AdminCreateKvEntry200Response.js → AdminCreateLeaderboard200Response.js} +22 -22
  32. package/dist/model/{AdminEndLeaderboard200ResponseData.js → AdminCreateLeaderboard200ResponseData.js} +32 -32
  33. package/dist/model/AdminCreateLeaderboardRequest.js +1 -1
  34. package/dist/model/AdminCreateNotificationRequest.js +1 -1
  35. package/dist/model/{DeleteNotifications200Response.js → AdminDeleteChatConversation200Response.js} +18 -19
  36. package/dist/model/{AdminUnlockAchievementRequest.js → AdminGrantAchievementRequest.js} +21 -21
  37. package/dist/model/AdminIncrementAchievementRequest.js +1 -1
  38. package/dist/model/AdminListAchievements200Response.js +5 -5
  39. package/dist/model/{AdminUpdateAchievement200Response.js → AdminListAchievements200ResponseDataInner.js} +28 -28
  40. package/dist/model/AdminListChatMessages200Response.js +5 -5
  41. package/dist/model/AdminListChatMessages200ResponseDataInner.js +1 -1
  42. package/dist/model/AdminListGroups200Response.js +5 -5
  43. package/dist/model/AdminListKvEntries200Response.js +9 -9
  44. package/dist/model/AdminListLobbies200Response.js +5 -5
  45. package/dist/model/AdminListLobbies200ResponseDataInner.js +1 -1
  46. package/dist/model/AdminListNotifications200Response.js +5 -5
  47. package/dist/model/AdminListNotifications200ResponseDataInner.js +1 -1
  48. package/dist/model/AdminListSessions200Response.js +5 -5
  49. package/dist/model/AdminListSessions200ResponseDataInner.js +1 -1
  50. package/dist/model/AdminRevokeAchievementRequest.js +1 -1
  51. package/dist/model/AdminSubmitLeaderboardScoreRequest.js +1 -1
  52. package/dist/model/AdminUpdateAchievementRequest.js +1 -1
  53. package/dist/model/AdminUpdateGroup200Response.js +1 -1
  54. package/dist/model/AdminUpdateGroupRequest.js +1 -1
  55. package/dist/model/AdminUpdateKvEntryRequest.js +1 -1
  56. package/dist/model/{AdminSubmitLeaderboardScore200Response.js → AdminUpdateLeaderboardRecord200Response.js} +22 -22
  57. package/dist/model/{AdminSubmitLeaderboardScore200ResponseData.js → AdminUpdateLeaderboardRecord200ResponseData.js} +26 -26
  58. package/dist/model/AdminUpdateLeaderboardRecordRequest.js +1 -1
  59. package/dist/model/AdminUpdateLeaderboardRequest.js +1 -1
  60. package/dist/model/AdminUpdateLobby200Response.js +1 -1
  61. package/dist/model/AdminUpdateUser200Response.js +1 -1
  62. package/dist/model/AdminUpdateUser200ResponseData.js +1 -1
  63. package/dist/model/AdminUpdateUserRequest.js +1 -1
  64. package/dist/model/{AdminEndLeaderboard200Response.js → AdminUpsertKv200Response.js} +22 -22
  65. package/dist/model/{AdminListKvEntries200ResponseDataInner.js → AdminUpsertKv200ResponseData.js} +25 -25
  66. package/dist/model/{AdminCreateKvEntryRequest.js → AdminUpsertKvRequest.js} +24 -24
  67. package/dist/model/{ListGroupMembers200ResponseDataInner.js → ApproveJoinRequest200Response.js} +28 -28
  68. package/dist/model/CallHook200Response.js +1 -1
  69. package/dist/model/CallHookRequest.js +1 -1
  70. package/dist/model/CancelJoinRequest200Response.js +1 -1
  71. package/dist/model/ChatUnreadCount200Response.js +1 -1
  72. package/dist/model/CreateGroupRequest.js +1 -1
  73. package/dist/model/CreateLobbyRequest.js +1 -1
  74. package/dist/model/CreatePartyRequest.js +1 -1
  75. package/dist/model/{InviteToGroup200Response.js → DeclineGroupInvite200Response.js} +18 -19
  76. package/dist/model/DeleteNotificationsRequest.js +1 -1
  77. package/dist/model/DeviceLoginRequest.js +1 -1
  78. package/dist/model/ErrorResponse.js +1 -1
  79. package/dist/model/GetCurrentUser200Response.js +1 -1
  80. package/dist/model/GetCurrentUser200ResponseLinkedProviders.js +1 -1
  81. package/dist/model/GetKv200Response.js +1 -1
  82. package/dist/model/GetLobby200Response.js +5 -5
  83. package/dist/model/GetMyRecord200Response.js +5 -5
  84. package/dist/model/{ListLeaderboardRecords200ResponseDataInner.js → GetMyRecord200ResponseData.js} +23 -23
  85. package/dist/model/HealthResponse.js +1 -1
  86. package/dist/model/{InviteToGroupRequest.js → InviteToPartyRequest.js} +22 -22
  87. package/dist/model/ListBlockedFriends200Response.js +5 -5
  88. package/dist/model/ListBlockedFriends200ResponseDataInner.js +1 -1
  89. package/dist/model/ListBlockedFriends200ResponseDataInnerRequester.js +1 -1
  90. package/dist/model/ListChatMessages200Response.js +5 -5
  91. package/dist/model/{GetChatMessage200Response.js → ListChatMessages200ResponseDataInner.js} +28 -28
  92. package/dist/model/ListFriendRequests200Response.js +1 -1
  93. package/dist/model/ListFriendRequests200ResponseIncomingInner.js +1 -1
  94. package/dist/model/ListFriendRequests200ResponseIncomingInnerRequester.js +1 -1
  95. package/dist/model/ListFriendRequests200ResponseMeta.js +1 -1
  96. package/dist/model/ListFriends200Response.js +5 -5
  97. package/dist/model/ListFriends200ResponseDataInner.js +1 -1
  98. package/dist/model/{AdminListNotifications200ResponseMeta.js → ListFriends200ResponseMeta.js} +23 -23
  99. package/dist/model/ListGroupMembers200Response.js +9 -9
  100. package/dist/model/ListJoinRequests200Response.js +5 -5
  101. package/dist/model/ListLeaderboardRecords200Response.js +9 -9
  102. package/dist/model/ListLeaderboards200Response.js +9 -9
  103. package/dist/model/ListLobbies200Response.js +5 -5
  104. package/dist/model/ListLobbies200ResponseDataInner.js +1 -1
  105. package/dist/model/ListMyGroups200Response.js +5 -5
  106. package/dist/model/ListMyGroups200ResponseDataInner.js +1 -1
  107. package/dist/model/ListPartyInvitations200ResponseInner.js +1 -1
  108. package/dist/model/ListRecordsAroundUser200Response.js +5 -5
  109. package/dist/model/ListSentInvitations200Response.js +5 -5
  110. package/dist/model/ListSentInvitations200ResponseDataInner.js +1 -1
  111. package/dist/model/LoginRequest.js +1 -1
  112. package/dist/model/MarkChatReadRequest.js +1 -1
  113. package/dist/model/{UserAchievements200Response.js → MyAchievements200Response.js} +27 -27
  114. package/dist/model/{UserAchievements200ResponseDataInner.js → MyAchievements200ResponseDataInner.js} +28 -28
  115. package/dist/model/NotifyGroup200Response.js +1 -1
  116. package/dist/model/NotifyGroupRequest.js +1 -1
  117. package/dist/model/OAuthSessionData.js +1 -1
  118. package/dist/model/OAuthSessionDataDetails.js +1 -1
  119. package/dist/model/OAuthSessionStatus.js +1 -1
  120. package/dist/model/OauthApiCallback200Response.js +1 -1
  121. package/dist/model/OauthApiCallbackRequest.js +1 -1
  122. package/dist/model/OauthCallbackApiAppleIosRequest.js +1 -1
  123. package/dist/model/OauthGoogleIdTokenRequest.js +1 -1
  124. package/dist/model/OauthRequest200Response.js +1 -1
  125. package/dist/model/OauthSessionStatus404Response.js +1 -1
  126. package/dist/model/PartyCreateLobbyRequest.js +1 -1
  127. package/dist/model/PartyJoinLobbyRequest.js +1 -1
  128. package/dist/model/{AdminCreateNotification400Response.js → PaymentsEntitlements401Response.js} +18 -18
  129. package/dist/model/PaymentsSteamCheckoutRequest.js +1 -1
  130. package/dist/model/PaymentsSteamFinalizeRequest.js +1 -1
  131. package/dist/model/PaymentsStripeCheckoutRequest.js +1 -1
  132. package/dist/model/QuickJoinRequest.js +1 -1
  133. package/dist/model/RefreshToken200Response.js +1 -1
  134. package/dist/model/RefreshToken200ResponseData.js +1 -1
  135. package/dist/model/RefreshTokenRequest.js +1 -1
  136. package/dist/model/ResolveLeaderboardSlugs200Response.js +4 -4
  137. package/dist/model/{ListLeaderboards200ResponseDataInner.js → ResolveLeaderboardSlugs200ResponseDataValue.js} +33 -33
  138. package/dist/model/ResolveLeaderboardSlugsRequest.js +1 -1
  139. package/dist/model/SearchUsers200Response.js +5 -5
  140. package/dist/model/SearchUsers200ResponseDataInner.js +1 -1
  141. package/dist/model/SendChatMessageRequest.js +1 -1
  142. package/dist/model/SendNotificationRequest.js +1 -1
  143. package/dist/model/UpdateChatMessageRequest.js +1 -1
  144. package/dist/model/{UpdateCurrentUserPassword400Response.js → UpdateCurrentUserDisplayName400Response.js} +19 -19
  145. package/dist/model/UpdateCurrentUserDisplayNameRequest.js +1 -1
  146. package/dist/model/UpdateCurrentUserPasswordRequest.js +1 -1
  147. package/dist/model/UpdateGroupRequest.js +1 -1
  148. package/dist/model/UpdateLobbyRequest.js +1 -1
  149. package/dist/model/UpdatePartyRequest.js +1 -1
  150. package/package.json +1 -1
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
- var _AdminCreateKvEntry200Response = _interopRequireDefault(require("../model/AdminCreateKvEntry200Response"));
9
- var _AdminCreateKvEntryRequest = _interopRequireDefault(require("../model/AdminCreateKvEntryRequest"));
10
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
11
8
  var _AdminListKvEntries200Response = _interopRequireDefault(require("../model/AdminListKvEntries200Response"));
12
9
  var _AdminUpdateKvEntryRequest = _interopRequireDefault(require("../model/AdminUpdateKvEntryRequest"));
10
+ var _AdminUpsertKv200Response = _interopRequireDefault(require("../model/AdminUpsertKv200Response"));
11
+ var _AdminUpsertKvRequest = _interopRequireDefault(require("../model/AdminUpsertKvRequest"));
12
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
14
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
15
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -20,7 +20,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
20
20
  * Game Server API
21
21
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
22
22
  *
23
- * The version of the OpenAPI document: 1.0.1001
23
+ * The version of the OpenAPI document: 1.0.1004
24
24
  *
25
25
  *
26
26
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -49,14 +49,14 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
49
49
  /**
50
50
  * Create KV entry (admin)
51
51
  * @param {Object} opts Optional parameters
52
- * @param {module:model/AdminCreateKvEntryRequest} [adminCreateKvEntryRequest] KV entry
53
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminCreateKvEntry200Response} and HTTP response
52
+ * @param {module:model/AdminUpsertKvRequest} [adminUpsertKvRequest] KV entry
53
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpsertKv200Response} and HTTP response
54
54
  */
55
55
  return _createClass(AdminKVApi, [{
56
56
  key: "adminCreateKvEntryWithHttpInfo",
57
57
  value: function adminCreateKvEntryWithHttpInfo(opts) {
58
58
  opts = opts || {};
59
- var postBody = opts['adminCreateKvEntryRequest'];
59
+ var postBody = opts['adminUpsertKvRequest'];
60
60
  var pathParams = {};
61
61
  var queryParams = {};
62
62
  var headerParams = {};
@@ -64,15 +64,15 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
64
64
  var authNames = ['authorization'];
65
65
  var contentTypes = ['application/json'];
66
66
  var accepts = ['application/json'];
67
- var returnType = _AdminCreateKvEntry200Response["default"];
67
+ var returnType = _AdminUpsertKv200Response["default"];
68
68
  return this.apiClient.callApi('/api/v1/admin/kv/entries', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
69
69
  }
70
70
 
71
71
  /**
72
72
  * Create KV entry (admin)
73
73
  * @param {Object} opts Optional parameters
74
- * @param {module:model/AdminCreateKvEntryRequest} opts.adminCreateKvEntryRequest KV entry
75
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminCreateKvEntry200Response}
74
+ * @param {module:model/AdminUpsertKvRequest} opts.adminUpsertKvRequest KV entry
75
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpsertKv200Response}
76
76
  */
77
77
  }, {
78
78
  key: "adminCreateKvEntry",
@@ -227,7 +227,7 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
227
227
  * @param {Number} id
228
228
  * @param {Object} opts Optional parameters
229
229
  * @param {module:model/AdminUpdateKvEntryRequest} [adminUpdateKvEntryRequest] KV entry patch
230
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminCreateKvEntry200Response} and HTTP response
230
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpsertKv200Response} and HTTP response
231
231
  */
232
232
  }, {
233
233
  key: "adminUpdateKvEntryWithHttpInfo",
@@ -247,7 +247,7 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
247
247
  var authNames = ['authorization'];
248
248
  var contentTypes = ['application/json'];
249
249
  var accepts = ['application/json'];
250
- var returnType = _AdminCreateKvEntry200Response["default"];
250
+ var returnType = _AdminUpsertKv200Response["default"];
251
251
  return this.apiClient.callApi('/api/v1/admin/kv/entries/{id}', 'PATCH', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
252
252
  }
253
253
 
@@ -256,7 +256,7 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
256
256
  * @param {Number} id
257
257
  * @param {Object} opts Optional parameters
258
258
  * @param {module:model/AdminUpdateKvEntryRequest} opts.adminUpdateKvEntryRequest KV entry patch
259
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminCreateKvEntry200Response}
259
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpsertKv200Response}
260
260
  */
261
261
  }, {
262
262
  key: "adminUpdateKvEntry",
@@ -269,14 +269,14 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
269
269
  /**
270
270
  * Upsert KV by key (admin)
271
271
  * @param {Object} opts Optional parameters
272
- * @param {module:model/AdminCreateKvEntryRequest} [adminCreateKvEntryRequest] KV upsert
273
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminCreateKvEntry200Response} and HTTP response
272
+ * @param {module:model/AdminUpsertKvRequest} [adminUpsertKvRequest] KV upsert
273
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpsertKv200Response} and HTTP response
274
274
  */
275
275
  }, {
276
276
  key: "adminUpsertKvWithHttpInfo",
277
277
  value: function adminUpsertKvWithHttpInfo(opts) {
278
278
  opts = opts || {};
279
- var postBody = opts['adminCreateKvEntryRequest'];
279
+ var postBody = opts['adminUpsertKvRequest'];
280
280
  var pathParams = {};
281
281
  var queryParams = {};
282
282
  var headerParams = {};
@@ -284,15 +284,15 @@ var AdminKVApi = exports["default"] = /*#__PURE__*/function () {
284
284
  var authNames = ['authorization'];
285
285
  var contentTypes = ['application/json'];
286
286
  var accepts = ['application/json'];
287
- var returnType = _AdminCreateKvEntry200Response["default"];
287
+ var returnType = _AdminUpsertKv200Response["default"];
288
288
  return this.apiClient.callApi('/api/v1/admin/kv', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
289
289
  }
290
290
 
291
291
  /**
292
292
  * Upsert KV by key (admin)
293
293
  * @param {Object} opts Optional parameters
294
- * @param {module:model/AdminCreateKvEntryRequest} opts.adminCreateKvEntryRequest KV upsert
295
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminCreateKvEntry200Response}
294
+ * @param {module:model/AdminUpsertKvRequest} opts.adminUpsertKvRequest KV upsert
295
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpsertKv200Response}
296
296
  */
297
297
  }, {
298
298
  key: "adminUpsertKv",
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
+ var _AdminCreateLeaderboard200Response = _interopRequireDefault(require("../model/AdminCreateLeaderboard200Response"));
8
9
  var _AdminCreateLeaderboardRequest = _interopRequireDefault(require("../model/AdminCreateLeaderboardRequest"));
9
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
10
- var _AdminEndLeaderboard200Response = _interopRequireDefault(require("../model/AdminEndLeaderboard200Response"));
11
- var _AdminSubmitLeaderboardScore200Response = _interopRequireDefault(require("../model/AdminSubmitLeaderboardScore200Response"));
12
10
  var _AdminSubmitLeaderboardScoreRequest = _interopRequireDefault(require("../model/AdminSubmitLeaderboardScoreRequest"));
11
+ var _AdminUpdateLeaderboardRecord200Response = _interopRequireDefault(require("../model/AdminUpdateLeaderboardRecord200Response"));
13
12
  var _AdminUpdateLeaderboardRecordRequest = _interopRequireDefault(require("../model/AdminUpdateLeaderboardRecordRequest"));
14
13
  var _AdminUpdateLeaderboardRequest = _interopRequireDefault(require("../model/AdminUpdateLeaderboardRequest"));
14
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
16
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
17
17
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -22,7 +22,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
22
22
  * Game Server API
23
23
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
24
24
  *
25
- * The version of the OpenAPI document: 1.0.1001
25
+ * The version of the OpenAPI document: 1.0.1004
26
26
  *
27
27
  *
28
28
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -52,7 +52,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
52
52
  * Create leaderboard (admin)
53
53
  * @param {Object} opts Optional parameters
54
54
  * @param {module:model/AdminCreateLeaderboardRequest} [adminCreateLeaderboardRequest] Leaderboard
55
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminEndLeaderboard200Response} and HTTP response
55
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminCreateLeaderboard200Response} and HTTP response
56
56
  */
57
57
  return _createClass(AdminLeaderboardsApi, [{
58
58
  key: "adminCreateLeaderboardWithHttpInfo",
@@ -66,7 +66,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
66
66
  var authNames = ['authorization'];
67
67
  var contentTypes = ['application/json'];
68
68
  var accepts = ['application/json'];
69
- var returnType = _AdminEndLeaderboard200Response["default"];
69
+ var returnType = _AdminCreateLeaderboard200Response["default"];
70
70
  return this.apiClient.callApi('/api/v1/admin/leaderboards', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
71
71
  }
72
72
 
@@ -74,7 +74,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
74
74
  * Create leaderboard (admin)
75
75
  * @param {Object} opts Optional parameters
76
76
  * @param {module:model/AdminCreateLeaderboardRequest} opts.adminCreateLeaderboardRequest Leaderboard
77
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminEndLeaderboard200Response}
77
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminCreateLeaderboard200Response}
78
78
  */
79
79
  }, {
80
80
  key: "adminCreateLeaderboard",
@@ -218,7 +218,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
218
218
  /**
219
219
  * End leaderboard (admin)
220
220
  * @param {Number} id
221
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminEndLeaderboard200Response} and HTTP response
221
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminCreateLeaderboard200Response} and HTTP response
222
222
  */
223
223
  }, {
224
224
  key: "adminEndLeaderboardWithHttpInfo",
@@ -237,14 +237,14 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
237
237
  var authNames = ['authorization'];
238
238
  var contentTypes = [];
239
239
  var accepts = ['application/json'];
240
- var returnType = _AdminEndLeaderboard200Response["default"];
240
+ var returnType = _AdminCreateLeaderboard200Response["default"];
241
241
  return this.apiClient.callApi('/api/v1/admin/leaderboards/{id}/end', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
242
242
  }
243
243
 
244
244
  /**
245
245
  * End leaderboard (admin)
246
246
  * @param {Number} id
247
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminEndLeaderboard200Response}
247
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminCreateLeaderboard200Response}
248
248
  */
249
249
  }, {
250
250
  key: "adminEndLeaderboard",
@@ -259,7 +259,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
259
259
  * @param {Number} id
260
260
  * @param {Object} opts Optional parameters
261
261
  * @param {module:model/AdminSubmitLeaderboardScoreRequest} [adminSubmitLeaderboardScoreRequest] Score submission
262
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminSubmitLeaderboardScore200Response} and HTTP response
262
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpdateLeaderboardRecord200Response} and HTTP response
263
263
  */
264
264
  }, {
265
265
  key: "adminSubmitLeaderboardScoreWithHttpInfo",
@@ -279,7 +279,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
279
279
  var authNames = ['authorization'];
280
280
  var contentTypes = ['application/json'];
281
281
  var accepts = ['application/json'];
282
- var returnType = _AdminSubmitLeaderboardScore200Response["default"];
282
+ var returnType = _AdminUpdateLeaderboardRecord200Response["default"];
283
283
  return this.apiClient.callApi('/api/v1/admin/leaderboards/{id}/records', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
284
284
  }
285
285
 
@@ -288,7 +288,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
288
288
  * @param {Number} id
289
289
  * @param {Object} opts Optional parameters
290
290
  * @param {module:model/AdminSubmitLeaderboardScoreRequest} opts.adminSubmitLeaderboardScoreRequest Score submission
291
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminSubmitLeaderboardScore200Response}
291
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpdateLeaderboardRecord200Response}
292
292
  */
293
293
  }, {
294
294
  key: "adminSubmitLeaderboardScore",
@@ -303,7 +303,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
303
303
  * @param {Number} id
304
304
  * @param {Object} opts Optional parameters
305
305
  * @param {module:model/AdminUpdateLeaderboardRequest} [adminUpdateLeaderboardRequest] Leaderboard patch
306
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminEndLeaderboard200Response} and HTTP response
306
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminCreateLeaderboard200Response} and HTTP response
307
307
  */
308
308
  }, {
309
309
  key: "adminUpdateLeaderboardWithHttpInfo",
@@ -323,7 +323,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
323
323
  var authNames = ['authorization'];
324
324
  var contentTypes = ['application/json'];
325
325
  var accepts = ['application/json'];
326
- var returnType = _AdminEndLeaderboard200Response["default"];
326
+ var returnType = _AdminCreateLeaderboard200Response["default"];
327
327
  return this.apiClient.callApi('/api/v1/admin/leaderboards/{id}', 'PATCH', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
328
328
  }
329
329
 
@@ -332,7 +332,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
332
332
  * @param {Number} id
333
333
  * @param {Object} opts Optional parameters
334
334
  * @param {module:model/AdminUpdateLeaderboardRequest} opts.adminUpdateLeaderboardRequest Leaderboard patch
335
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminEndLeaderboard200Response}
335
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminCreateLeaderboard200Response}
336
336
  */
337
337
  }, {
338
338
  key: "adminUpdateLeaderboard",
@@ -348,7 +348,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
348
348
  * @param {Number} recordId
349
349
  * @param {Object} opts Optional parameters
350
350
  * @param {module:model/AdminUpdateLeaderboardRecordRequest} [adminUpdateLeaderboardRecordRequest] Record patch
351
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminSubmitLeaderboardScore200Response} and HTTP response
351
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminUpdateLeaderboardRecord200Response} and HTTP response
352
352
  */
353
353
  }, {
354
354
  key: "adminUpdateLeaderboardRecordWithHttpInfo",
@@ -373,7 +373,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
373
373
  var authNames = ['authorization'];
374
374
  var contentTypes = ['application/json'];
375
375
  var accepts = ['application/json'];
376
- var returnType = _AdminSubmitLeaderboardScore200Response["default"];
376
+ var returnType = _AdminUpdateLeaderboardRecord200Response["default"];
377
377
  return this.apiClient.callApi('/api/v1/admin/leaderboards/{id}/records/{record_id}', 'PATCH', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
378
378
  }
379
379
 
@@ -383,7 +383,7 @@ var AdminLeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
383
383
  * @param {Number} recordId
384
384
  * @param {Object} opts Optional parameters
385
385
  * @param {module:model/AdminUpdateLeaderboardRecordRequest} opts.adminUpdateLeaderboardRecordRequest Record patch
386
- * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminSubmitLeaderboardScore200Response}
386
+ * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminUpdateLeaderboardRecord200Response}
387
387
  */
388
388
  }, {
389
389
  key: "adminUpdateLeaderboardRecord",
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
9
8
  var _AdminListLobbies200Response = _interopRequireDefault(require("../model/AdminListLobbies200Response"));
10
9
  var _AdminUpdateLobby200Response = _interopRequireDefault(require("../model/AdminUpdateLobby200Response"));
10
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
11
11
  var _UpdateLobbyRequest = _interopRequireDefault(require("../model/UpdateLobbyRequest"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
13
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -19,7 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
19
19
  * Game Server API
20
20
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
21
21
  *
22
- * The version of the OpenAPI document: 1.0.1001
22
+ * The version of the OpenAPI document: 1.0.1004
23
23
  *
24
24
  *
25
25
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
9
8
  var _AdminCreateNotificationRequest = _interopRequireDefault(require("../model/AdminCreateNotificationRequest"));
10
9
  var _AdminListNotifications200Response = _interopRequireDefault(require("../model/AdminListNotifications200Response"));
11
10
  var _AdminListNotifications200ResponseDataInner = _interopRequireDefault(require("../model/AdminListNotifications200ResponseDataInner"));
11
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
13
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
14
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -19,7 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
19
19
  * Game Server API
20
20
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
21
21
  *
22
- * The version of the OpenAPI document: 1.0.1001
22
+ * The version of the OpenAPI document: 1.0.1004
23
23
  *
24
24
  *
25
25
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
9
8
  var _AdminListSessions200Response = _interopRequireDefault(require("../model/AdminListSessions200Response"));
9
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
11
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
12
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -17,7 +17,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  * Game Server API
18
18
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
19
19
  *
20
- * The version of the OpenAPI document: 1.0.1001
20
+ * The version of the OpenAPI document: 1.0.1004
21
21
  *
22
22
  *
23
23
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
9
8
  var _AdminUpdateUser200Response = _interopRequireDefault(require("../model/AdminUpdateUser200Response"));
10
9
  var _AdminUpdateUserRequest = _interopRequireDefault(require("../model/AdminUpdateUserRequest"));
10
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
13
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -18,7 +18,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
18
18
  * Game Server API
19
19
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
20
20
  *
21
- * The version of the OpenAPI document: 1.0.1001
21
+ * The version of the OpenAPI document: 1.0.1004
22
22
  *
23
23
  *
24
24
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _ApiClient = _interopRequireDefault(require("../ApiClient"));
8
- var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
9
8
  var _DeviceLoginRequest = _interopRequireDefault(require("../model/DeviceLoginRequest"));
10
9
  var _ErrorResponse = _interopRequireDefault(require("../model/ErrorResponse"));
11
10
  var _LoginRequest = _interopRequireDefault(require("../model/LoginRequest"));
@@ -16,6 +15,7 @@ var _OauthCallbackApiAppleIosRequest = _interopRequireDefault(require("../model/
16
15
  var _OauthGoogleIdTokenRequest = _interopRequireDefault(require("../model/OauthGoogleIdTokenRequest"));
17
16
  var _OauthRequest200Response = _interopRequireDefault(require("../model/OauthRequest200Response"));
18
17
  var _OauthSessionStatus404Response = _interopRequireDefault(require("../model/OauthSessionStatus404Response"));
18
+ var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
19
19
  var _RefreshToken200Response = _interopRequireDefault(require("../model/RefreshToken200Response"));
20
20
  var _RefreshTokenRequest = _interopRequireDefault(require("../model/RefreshTokenRequest"));
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -28,7 +28,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
28
28
  * Game Server API
29
29
  * API for the Gamend Game Server. Provides HTTP REST API, real-time WebSocket channels, and WebRTC DataChannels for low-latency game data. Features authentication, users, lobbies, groups, parties, friends, chat, notifications, achievements, leaderboards, payments, server scripting, and admin portal. ## **1. Authentication** This API uses JWT (JSON Web Tokens) with access and refresh tokens: ### **1.1 Getting Tokens** - **Email/Password**: POST to `/api/v1/login` with email and password - **Device (SDK)**: POST to `/api/v1/login` with a `device_id` string (creates/returns a device user) - **Discord OAuth**: Use `/api/v1/auth/discord` flow - **Google OAuth**: Use `/api/v1/auth/google` flow - **Facebook OAuth**: Use `/api/v1/auth/facebook` flow - **Apple Sign In**: Use `/auth/apple` browser flow or apple sdk flow - **Steam (OpenID)**: Use `/api/v1/auth/steam` flow Both methods return: - `access_token` - Short-lived (15 min), use for API requests - `refresh_token` - Long-lived (30 days), use to get new access tokens ### **1.2 Using Tokens** Include the access token in the Authorization header: ``` Authorization: Bearer <access_token> ``` ### **1.3 Refreshing Tokens** When your access token expires, use POST `/api/v1/refresh` with your refresh token to get a new access token. ## **2. Users** Users endpoints cover the user lifecycle and profile features. Key highlights: - **Registration and login** (email/password, device token for SDKs, and OAuth providers) - **Profile metadata** (JSON blob per user) and editable profile fields - **Account lifecycle**: password reset, email confirmation, and account deletion - **Sessions & tokens**: both browser sessions and JWT-based API tokens are supported ## **3. Friends** The Friends domain offers lightweight social features: - **Friend requests** (send / accept / reject / block flows) - **Friend listing & pagination**, with basic privacy controls - **Domain helpers** to manage and query friend relationships from API or UI contexts ## **4. Lobbies** Lobbies provide matchmaking / room management primitives. Highlights: - **Create / list / update / delete** lobbies with rich metadata (mode, region, tags) - **Host-managed or hostless** modes (hostless allowed internally, not creatable via public API) - **Membership management**: join, leave, kick users, and automatic host transfer - **Controls & protection**: max users, hidden/locked states, and optional password protection - **Hidden lobbies** are excluded from public listings; public listing endpoints are paginated ## **5. Notifications** Persistent user-to-user notifications that survive across sessions: - **Send notifications** to accepted friends with a title, optional content, and optional metadata - **List own notifications** with pagination (ordered oldest-first) - **Delete notifications** by ID (single or batch) - **Real-time delivery** via the user WebSocket channel (`\"notification\"` events) - **Offline delivery**: undeleted notifications are replayed on WebSocket reconnect ## **6. Groups** Groups provide persistent community management for players: - **Three group types**: `public` (anyone joins directly), `private` (users request to join, admins approve), `hidden` (invite-only, never listed) - **Membership roles**: `admin` and `member`, with promote/demote capabilities - **Join requests**: for private groups, users submit requests that admins approve or reject - **Invitations**: admins can invite users directly (blocked users are rejected) - **CRUD operations**: create, update, delete groups with metadata support - **Group chat**: integrated via the Chat API with `chat_type: \"group\"` ## **7. Parties** Ephemeral groups of users for short-lived sessions (e.g., matchmaking squads): - **Invite-only joining**: the party leader sends invites by user ID to friends or shared-group members - **Invite flow**: `POST /parties/invite` → recipient accepts via `POST /parties/invite/accept` or declines via `POST /parties/invite/decline`; leader can cancel via `POST /parties/invite/cancel` - **Invite visibility**: leader can list sent invites (`GET /parties/invitations/sent`); recipient can list received invites (`GET /parties/invitations`) - **Connection requirement**: invites can only be sent to users who are friends or share at least one group with the leader - **One party at a time**: a user can only be in one party; accepting an invite while already in a party is rejected - **Leader management**: the creator is the leader; leadership can be transferred - **Lobby integration**: parties can create or join lobbies as a group - **Party chat**: integrated via the Chat API with `chat_type: \"party\"` - **Real-time events** via the party WebSocket channel ## **8. Chat** Real-time messaging across multiple conversation types: - **Chat types**: `lobby` (within a lobby), `group` (within a group), `party` (within a party), `friend` (DMs between friends) - **Send messages** with content, optional metadata, and automatic access validation - **List messages** with pagination (newest first) - **Read tracking**: mark messages as read and get unread counts per conversation - **Real-time delivery** via PubSub and WebSocket channels - **Moderation hooks**: `before_chat_message` pipeline hook for filtering/blocking ## **9. Leaderboards** Server-managed ranked scoreboards: - **Multiple leaderboards**: create named leaderboards with configurable sort order - **Score submission**: submit scores with optional metadata - **Rankings**: retrieve paginated rankings with user details - **Reset support**: leaderboards can be reset periodically ## **10. Key-Value Storage** Per-user persistent key-value storage for game state, preferences, and settings: - **Get/set/delete** key-value pairs scoped to the authenticated user - **List keys** with optional prefix filtering - **Metadata support**: values can include arbitrary JSON metadata ## **11. Achievements** Track player accomplishments with progress-based or instant-unlock achievements: - **Achievement definitions**: admin-created with slug, title, description, icon, sort order, and optional progress target - **Progress tracking**: increment progress toward a target; auto-unlocks when progress reaches the target - **Instant unlock**: directly unlock achievements without progress tracking - **Hidden achievements**: details obscured (\"???\") until unlocked by the user - **Public listings**: paginated, optionally filtered; authenticated users see their own progress - **Admin management**: create, update, delete, grant, revoke, unlock, and increment achievements ## **12. Real-time: WebSocket Channels** The server provides real-time communication via Phoenix WebSocket channels. Connect to the WebSocket endpoint and join topic-based channels for live updates. ### **12.1 Connection** Connect to `wss://your-server.com/socket` with your JWT token as a parameter: ``` const socket = new Socket(\"wss://your-server.com/socket\", { params: { token: \"<access_token>\" } }) socket.connect() ``` ### **12.2 Available Channels** - **User channel** (`user:<user_id>`): notifications, friend events, achievement unlocks, party/group invites - **Lobby channel** (`lobby:<lobby_id>`): lobby member joins/leaves, lobby updates, lobby chat - **Lobbies channel** (`lobbies`): global lobby list changes (created, updated, deleted) - **Group channel** (`group:<group_id>`): group member changes, group updates, group chat - **Groups channel** (`groups`): global group list changes - **Party channel** (`party:<party_id>`): party member changes, party updates, party chat ### **12.3 JS SDK Helper** The `GameRealtime` class (included in this SDK) wraps Phoenix.Socket with convenient channel helpers: ```javascript import { GameRealtime } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', accessToken) const userChannel = realtime.joinUserChannel(userId) userChannel.on('notification', payload => console.log(payload)) ``` Requires the `phoenix` npm package as a peer dependency: `npm install phoenix` ## **13. Real-time: WebRTC DataChannels** For low-latency game data, the server supports WebRTC DataChannels alongside WebSocket. The server acts as a WebRTC peer (not P2P between clients). ### **13.1 How It Works** 1. Client connects via WebSocket and joins the **User channel** 2. Client sends an SDP offer over the channel (`webrtc:offer` event) 3. Server responds with an SDP answer (`webrtc:answer` event) 4. ICE candidates are exchanged (`webrtc:ice` events) 5. Once connected, named DataChannels carry game data at low latency ### **13.2 Default DataChannels** - **`events`** (reliable, ordered): important game events (player actions, state changes) - **`state`** (unreliable, unordered): high-frequency position/state sync ### **13.3 JS SDK Helper** The `GameWebRTC` class (included in this SDK, browser-only) handles signaling automatically: ```javascript import { GameRealtime, GameWebRTC } from '@ughuuu/game_server' const realtime = new GameRealtime('https://your-server.com', token) const userChannel = realtime.joinUserChannel(userId) const webrtc = new GameWebRTC(userChannel, { onData: (label, data) => console.log(label, data) }) await webrtc.connect() webrtc.send('events', JSON.stringify({ type: 'move', x: 10, y: 20 })) ```
30
30
  *
31
- * The version of the OpenAPI document: 1.0.1001
31
+ * The version of the OpenAPI document: 1.0.1004
32
32
  *
33
33
  *
34
34
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).