@ughuuu/game_server 1.0.988 → 1.0.990
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.
- package/README.md +3 -22
- package/dist/ApiClient.js +1 -1
- package/dist/api/AchievementsApi.js +1 -1
- package/dist/api/AdminAchievementsApi.js +1 -1
- package/dist/api/AdminChatApi.js +5 -5
- package/dist/api/AdminGroupsApi.js +1 -1
- package/dist/api/AdminKVApi.js +1 -1
- package/dist/api/AdminLeaderboardsApi.js +1 -1
- package/dist/api/AdminLobbiesApi.js +5 -5
- package/dist/api/AdminNotificationsApi.js +1 -1
- package/dist/api/AdminSessionsApi.js +1 -1
- package/dist/api/AdminUsersApi.js +1 -1
- package/dist/api/AuthenticationApi.js +7 -9
- package/dist/api/ChatApi.js +1 -1
- package/dist/api/FriendsApi.js +5 -5
- package/dist/api/GroupsApi.js +19 -24
- package/dist/api/HealthApi.js +1 -1
- package/dist/api/HooksApi.js +1 -1
- package/dist/api/KVApi.js +1 -1
- package/dist/api/LeaderboardsApi.js +1 -1
- package/dist/api/LobbiesApi.js +5 -5
- package/dist/api/NotificationsApi.js +9 -9
- package/dist/api/PartiesApi.js +14 -17
- package/dist/api/UsersApi.js +3 -3
- package/dist/index.js +0 -133
- package/dist/model/AcceptPartyInviteRequest.js +1 -1
- package/dist/model/AdminCreateAchievementRequest.js +1 -1
- package/dist/model/AdminCreateKvEntry200Response.js +1 -1
- package/dist/model/AdminCreateKvEntryRequest.js +1 -1
- package/dist/model/AdminCreateLeaderboardRequest.js +1 -1
- package/dist/model/AdminCreateNotification400Response.js +1 -1
- package/dist/model/AdminCreateNotificationRequest.js +1 -1
- package/dist/model/AdminEndLeaderboard200Response.js +1 -1
- package/dist/model/AdminEndLeaderboard200ResponseData.js +1 -1
- package/dist/model/AdminIncrementAchievementRequest.js +1 -1
- package/dist/model/AdminListAchievements200Response.js +1 -1
- package/dist/model/AdminListChatMessages200Response.js +1 -1
- package/dist/model/AdminListChatMessages200ResponseDataInner.js +1 -1
- package/dist/model/AdminListGroups200Response.js +1 -1
- package/dist/model/AdminListKvEntries200Response.js +1 -1
- package/dist/model/AdminListKvEntries200ResponseDataInner.js +1 -1
- package/dist/model/AdminListLobbies200Response.js +1 -1
- package/dist/model/AdminListLobbies200ResponseDataInner.js +1 -1
- package/dist/model/AdminListNotifications200Response.js +1 -1
- package/dist/model/AdminListNotifications200ResponseDataInner.js +1 -1
- package/dist/model/AdminListNotifications200ResponseMeta.js +1 -1
- package/dist/model/AdminListSessions200Response.js +1 -1
- package/dist/model/AdminListSessions200ResponseDataInner.js +1 -1
- package/dist/model/AdminRevokeAchievementRequest.js +1 -1
- package/dist/model/AdminSubmitLeaderboardScore200Response.js +1 -1
- package/dist/model/AdminSubmitLeaderboardScore200ResponseData.js +1 -1
- package/dist/model/AdminSubmitLeaderboardScoreRequest.js +1 -1
- package/dist/model/AdminUnlockAchievementRequest.js +1 -1
- package/dist/model/AdminUpdateAchievement200Response.js +1 -1
- package/dist/model/AdminUpdateAchievementRequest.js +1 -1
- package/dist/model/AdminUpdateGroup200Response.js +2 -1
- package/dist/model/AdminUpdateGroupRequest.js +1 -1
- package/dist/model/AdminUpdateKvEntryRequest.js +1 -1
- package/dist/model/AdminUpdateLeaderboardRecordRequest.js +1 -1
- package/dist/model/AdminUpdateLeaderboardRequest.js +1 -1
- package/dist/model/AdminUpdateLobby200Response.js +1 -1
- package/dist/model/AdminUpdateUser200Response.js +1 -1
- package/dist/model/AdminUpdateUser200ResponseData.js +1 -1
- package/dist/model/AdminUpdateUserRequest.js +1 -1
- package/dist/model/CallHook200Response.js +1 -1
- package/dist/model/CallHookRequest.js +1 -1
- package/dist/model/CancelJoinRequest200Response.js +1 -1
- package/dist/model/ChatUnreadCount200Response.js +1 -1
- package/dist/model/CreateGroupRequest.js +1 -1
- package/dist/model/CreateLobbyRequest.js +1 -1
- package/dist/model/CreatePartyRequest.js +1 -1
- package/dist/model/DeleteNotifications200Response.js +1 -1
- package/dist/model/DeleteNotificationsRequest.js +1 -1
- package/dist/model/DeviceLoginRequest.js +1 -1
- package/dist/model/ErrorResponse.js +1 -1
- package/dist/model/GetChatMessage200Response.js +1 -1
- package/dist/model/GetCurrentUser200Response.js +1 -1
- package/dist/model/GetCurrentUser200ResponseLinkedProviders.js +1 -1
- package/dist/model/GetKv200Response.js +1 -1
- package/dist/model/GetLobby200Response.js +5 -5
- package/dist/model/GetMyRecord200Response.js +1 -1
- package/dist/model/HealthResponse.js +1 -1
- package/dist/model/InviteToGroup200Response.js +1 -1
- package/dist/model/InviteToGroupRequest.js +1 -1
- package/dist/model/ListBlockedFriends200Response.js +1 -1
- package/dist/model/ListBlockedFriends200ResponseDataInner.js +1 -1
- package/dist/model/ListBlockedFriends200ResponseDataInnerRequester.js +1 -13
- package/dist/model/ListChatMessages200Response.js +1 -1
- package/dist/model/ListFriendRequests200Response.js +1 -1
- package/dist/model/ListFriendRequests200ResponseIncomingInner.js +1 -1
- package/dist/model/ListFriendRequests200ResponseIncomingInnerRequester.js +1 -1
- package/dist/model/ListFriendRequests200ResponseMeta.js +1 -1
- package/dist/model/ListFriends200Response.js +1 -1
- package/dist/model/ListFriends200ResponseDataInner.js +1 -13
- package/dist/model/ListGroupMembers200Response.js +1 -1
- package/dist/model/ListGroupMembers200ResponseDataInner.js +1 -1
- package/dist/model/ListJoinRequests200Response.js +1 -1
- package/dist/model/ListLeaderboardRecords200Response.js +1 -1
- package/dist/model/ListLeaderboardRecords200ResponseDataInner.js +1 -1
- package/dist/model/ListLeaderboards200Response.js +1 -1
- package/dist/model/ListLeaderboards200ResponseDataInner.js +1 -1
- package/dist/model/ListLobbies200Response.js +1 -1
- package/dist/model/ListLobbies200ResponseDataInner.js +1 -1
- package/dist/model/ListMyGroups200Response.js +1 -1
- package/dist/model/ListMyGroups200ResponseDataInner.js +2 -2
- package/dist/model/ListPartyInvitations200ResponseInner.js +1 -1
- package/dist/model/ListRecordsAroundUser200Response.js +1 -1
- package/dist/model/ListSentInvitations200Response.js +1 -1
- package/dist/model/ListSentInvitations200ResponseDataInner.js +1 -1
- package/dist/model/LoginRequest.js +1 -1
- package/dist/model/MarkChatReadRequest.js +1 -1
- package/dist/model/NotifyGroup200Response.js +1 -1
- package/dist/model/NotifyGroupRequest.js +1 -1
- package/dist/model/OAuthSessionData.js +1 -1
- package/dist/model/OAuthSessionDataDetails.js +1 -1
- package/dist/model/OAuthSessionStatus.js +1 -1
- package/dist/model/OauthApiCallback200Response.js +1 -1
- package/dist/model/OauthApiCallbackRequest.js +1 -1
- package/dist/model/OauthCallbackApiAppleIosRequest.js +1 -1
- package/dist/model/OauthGoogleIdTokenRequest.js +1 -1
- package/dist/model/OauthRequest200Response.js +1 -1
- package/dist/model/OauthSessionStatus404Response.js +1 -1
- package/dist/model/PartyCreateLobbyRequest.js +1 -1
- package/dist/model/PartyJoinLobbyRequest.js +1 -1
- package/dist/model/QuickJoinRequest.js +1 -1
- package/dist/model/RefreshToken200Response.js +1 -1
- package/dist/model/RefreshToken200ResponseData.js +1 -1
- package/dist/model/RefreshTokenRequest.js +1 -1
- package/dist/model/ResolveLeaderboardSlugs200Response.js +1 -1
- package/dist/model/ResolveLeaderboardSlugsRequest.js +1 -1
- package/dist/model/SearchUsers200Response.js +1 -1
- package/dist/model/SearchUsers200ResponseDataInner.js +1 -13
- package/dist/model/SendChatMessageRequest.js +1 -1
- package/dist/model/SendNotificationRequest.js +1 -1
- package/dist/model/ShowParty200Response.js +1 -1
- package/dist/model/ShowParty200ResponseMembersInner.js +1 -13
- package/dist/model/UpdateChatMessageRequest.js +1 -1
- package/dist/model/UpdateCurrentUserDisplayNameRequest.js +1 -1
- package/dist/model/UpdateCurrentUserPassword400Response.js +1 -1
- package/dist/model/UpdateCurrentUserPasswordRequest.js +1 -1
- package/dist/model/UpdateGroupRequest.js +1 -1
- package/dist/model/UpdateLobbyRequest.js +1 -1
- package/dist/model/UpdatePartyRequest.js +1 -1
- package/dist/model/UserAchievements200Response.js +1 -1
- package/dist/model/UserAchievements200ResponseDataInner.js +1 -1
- package/package.json +1 -1
- package/dist/model/AdminDeleteChatConversation200Response.js +0 -85
- package/dist/model/AdminUpdateLobbyRequest.js +0 -142
- package/dist/model/CancelGroupInvite200Response.js +0 -89
- package/dist/model/CancelPartyInviteRequest.js +0 -109
- package/dist/model/CreateFriendRequestRequest.js +0 -109
- package/dist/model/DeclinePartyInviteRequest.js +0 -109
- package/dist/model/DemoteGroupMemberRequest.js +0 -109
- package/dist/model/GetLobby200ResponseMembersInner.js +0 -146
- package/dist/model/InviteToPartyRequest.js +0 -109
- package/dist/model/KickGroupMemberRequest.js +0 -109
- package/dist/model/KickUserRequest.js +0 -109
- package/dist/model/LinkDeviceRequest.js +0 -112
- package/dist/model/ListGroupInvitations200Response.js +0 -124
- package/dist/model/ListGroupInvitations200ResponseDataInner.js +0 -167
- package/dist/model/ListNotifications200Response.js +0 -124
- package/dist/model/ListNotifications200ResponseDataInner.js +0 -161
- package/dist/model/Login200Response.js +0 -91
- package/dist/model/Login200ResponseData.js +0 -133
- package/dist/model/PromoteGroupMemberRequest.js +0 -109
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
|
|
8
8
|
var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
|
|
9
|
+
var _AdminListNotifications200Response = _interopRequireDefault(require("../model/AdminListNotifications200Response"));
|
|
10
|
+
var _AdminListNotifications200ResponseDataInner = _interopRequireDefault(require("../model/AdminListNotifications200ResponseDataInner"));
|
|
9
11
|
var _DeleteNotifications200Response = _interopRequireDefault(require("../model/DeleteNotifications200Response"));
|
|
10
12
|
var _DeleteNotificationsRequest = _interopRequireDefault(require("../model/DeleteNotificationsRequest"));
|
|
11
|
-
var _ListNotifications200Response = _interopRequireDefault(require("../model/ListNotifications200Response"));
|
|
12
|
-
var _ListNotifications200ResponseDataInner = _interopRequireDefault(require("../model/ListNotifications200ResponseDataInner"));
|
|
13
13
|
var _SendNotificationRequest = _interopRequireDefault(require("../model/SendNotificationRequest"));
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
15
|
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); }
|
|
@@ -21,7 +21,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
21
21
|
* Game Server API
|
|
22
22
|
* 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, 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 })) ```
|
|
23
23
|
*
|
|
24
|
-
* The version of the OpenAPI document: 1.0.
|
|
24
|
+
* The version of the OpenAPI document: 1.0.990
|
|
25
25
|
*
|
|
26
26
|
*
|
|
27
27
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -91,7 +91,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
91
91
|
* @param {Object} opts Optional parameters
|
|
92
92
|
* @param {Number} [page] Page number (1-based)
|
|
93
93
|
* @param {Number} [pageSize] Page size (max results per page)
|
|
94
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
94
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminListNotifications200Response} and HTTP response
|
|
95
95
|
*/
|
|
96
96
|
}, {
|
|
97
97
|
key: "listNotificationsWithHttpInfo",
|
|
@@ -108,7 +108,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
108
108
|
var authNames = ['authorization'];
|
|
109
109
|
var contentTypes = [];
|
|
110
110
|
var accepts = ['application/json'];
|
|
111
|
-
var returnType =
|
|
111
|
+
var returnType = _AdminListNotifications200Response["default"];
|
|
112
112
|
return this.apiClient.callApi('/api/v1/notifications', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -118,7 +118,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
118
118
|
* @param {Object} opts Optional parameters
|
|
119
119
|
* @param {Number} opts.page Page number (1-based)
|
|
120
120
|
* @param {Number} opts.pageSize Page size (max results per page)
|
|
121
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
121
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminListNotifications200Response}
|
|
122
122
|
*/
|
|
123
123
|
}, {
|
|
124
124
|
key: "listNotifications",
|
|
@@ -133,7 +133,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
133
133
|
* Send a notification to an accepted friend. The recipient will receive it in real-time (if connected) and it persists until deleted.
|
|
134
134
|
* @param {Object} opts Optional parameters
|
|
135
135
|
* @param {module:model/SendNotificationRequest} [sendNotificationRequest] Notification payload
|
|
136
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
136
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminListNotifications200ResponseDataInner} and HTTP response
|
|
137
137
|
*/
|
|
138
138
|
}, {
|
|
139
139
|
key: "sendNotificationWithHttpInfo",
|
|
@@ -147,7 +147,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
147
147
|
var authNames = ['authorization'];
|
|
148
148
|
var contentTypes = ['application/json'];
|
|
149
149
|
var accepts = ['application/json'];
|
|
150
|
-
var returnType =
|
|
150
|
+
var returnType = _AdminListNotifications200ResponseDataInner["default"];
|
|
151
151
|
return this.apiClient.callApi('/api/v1/notifications', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -156,7 +156,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
156
156
|
* Send a notification to an accepted friend. The recipient will receive it in real-time (if connected) and it persists until deleted.
|
|
157
157
|
* @param {Object} opts Optional parameters
|
|
158
158
|
* @param {module:model/SendNotificationRequest} opts.sendNotificationRequest Notification payload
|
|
159
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
159
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminListNotifications200ResponseDataInner}
|
|
160
160
|
*/
|
|
161
161
|
}, {
|
|
162
162
|
key: "sendNotification",
|
package/dist/api/PartiesApi.js
CHANGED
|
@@ -7,11 +7,8 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
|
|
8
8
|
var _AcceptPartyInviteRequest = _interopRequireDefault(require("../model/AcceptPartyInviteRequest"));
|
|
9
9
|
var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
|
|
10
|
-
var _CancelPartyInviteRequest = _interopRequireDefault(require("../model/CancelPartyInviteRequest"));
|
|
11
10
|
var _CreatePartyRequest = _interopRequireDefault(require("../model/CreatePartyRequest"));
|
|
12
|
-
var
|
|
13
|
-
var _InviteToPartyRequest = _interopRequireDefault(require("../model/InviteToPartyRequest"));
|
|
14
|
-
var _KickUserRequest = _interopRequireDefault(require("../model/KickUserRequest"));
|
|
11
|
+
var _InviteToGroupRequest = _interopRequireDefault(require("../model/InviteToGroupRequest"));
|
|
15
12
|
var _ListPartyInvitations200ResponseInner = _interopRequireDefault(require("../model/ListPartyInvitations200ResponseInner"));
|
|
16
13
|
var _PartyCreateLobbyRequest = _interopRequireDefault(require("../model/PartyCreateLobbyRequest"));
|
|
17
14
|
var _PartyJoinLobbyRequest = _interopRequireDefault(require("../model/PartyJoinLobbyRequest"));
|
|
@@ -27,7 +24,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
24
|
* Game Server API
|
|
28
25
|
* 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, 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 })) ```
|
|
29
26
|
*
|
|
30
|
-
* The version of the OpenAPI document: 1.0.
|
|
27
|
+
* The version of the OpenAPI document: 1.0.990
|
|
31
28
|
*
|
|
32
29
|
*
|
|
33
30
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -95,14 +92,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
95
92
|
* Cancel a pending party invite (leader only)
|
|
96
93
|
* Cancel an outstanding invite sent to a user. Only the leader can cancel.
|
|
97
94
|
* @param {Object} opts Optional parameters
|
|
98
|
-
* @param {module:model/
|
|
95
|
+
* @param {module:model/InviteToGroupRequest} [inviteToGroupRequest] Cancel parameters
|
|
99
96
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
100
97
|
*/
|
|
101
98
|
}, {
|
|
102
99
|
key: "cancelPartyInviteWithHttpInfo",
|
|
103
100
|
value: function cancelPartyInviteWithHttpInfo(opts) {
|
|
104
101
|
opts = opts || {};
|
|
105
|
-
var postBody = opts['
|
|
102
|
+
var postBody = opts['inviteToGroupRequest'];
|
|
106
103
|
var pathParams = {};
|
|
107
104
|
var queryParams = {};
|
|
108
105
|
var headerParams = {};
|
|
@@ -118,7 +115,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
118
115
|
* Cancel a pending party invite (leader only)
|
|
119
116
|
* Cancel an outstanding invite sent to a user. Only the leader can cancel.
|
|
120
117
|
* @param {Object} opts Optional parameters
|
|
121
|
-
* @param {module:model/
|
|
118
|
+
* @param {module:model/InviteToGroupRequest} opts.inviteToGroupRequest Cancel parameters
|
|
122
119
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
123
120
|
*/
|
|
124
121
|
}, {
|
|
@@ -171,14 +168,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
171
168
|
* Decline a party invite
|
|
172
169
|
* Decline a pending party invite. The PartyInvite record is marked as declined.
|
|
173
170
|
* @param {Object} opts Optional parameters
|
|
174
|
-
* @param {module:model/
|
|
171
|
+
* @param {module:model/AcceptPartyInviteRequest} [acceptPartyInviteRequest] Decline parameters
|
|
175
172
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
176
173
|
*/
|
|
177
174
|
}, {
|
|
178
175
|
key: "declinePartyInviteWithHttpInfo",
|
|
179
176
|
value: function declinePartyInviteWithHttpInfo(opts) {
|
|
180
177
|
opts = opts || {};
|
|
181
|
-
var postBody = opts['
|
|
178
|
+
var postBody = opts['acceptPartyInviteRequest'];
|
|
182
179
|
var pathParams = {};
|
|
183
180
|
var queryParams = {};
|
|
184
181
|
var headerParams = {};
|
|
@@ -194,7 +191,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
194
191
|
* Decline a party invite
|
|
195
192
|
* Decline a pending party invite. The PartyInvite record is marked as declined.
|
|
196
193
|
* @param {Object} opts Optional parameters
|
|
197
|
-
* @param {module:model/
|
|
194
|
+
* @param {module:model/AcceptPartyInviteRequest} opts.acceptPartyInviteRequest Decline parameters
|
|
198
195
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
199
196
|
*/
|
|
200
197
|
}, {
|
|
@@ -209,14 +206,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
209
206
|
* Invite a user to the party (leader only)
|
|
210
207
|
* The party leader invites a user by ID. The target must be a friend of the leader or share at least one group with the leader. A PartyInvite record is created and an informational notification is sent. The invite is independent of notifications.
|
|
211
208
|
* @param {Object} opts Optional parameters
|
|
212
|
-
* @param {module:model/
|
|
209
|
+
* @param {module:model/InviteToGroupRequest} [inviteToGroupRequest] Invite parameters
|
|
213
210
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
214
211
|
*/
|
|
215
212
|
}, {
|
|
216
213
|
key: "inviteToPartyWithHttpInfo",
|
|
217
214
|
value: function inviteToPartyWithHttpInfo(opts) {
|
|
218
215
|
opts = opts || {};
|
|
219
|
-
var postBody = opts['
|
|
216
|
+
var postBody = opts['inviteToGroupRequest'];
|
|
220
217
|
var pathParams = {};
|
|
221
218
|
var queryParams = {};
|
|
222
219
|
var headerParams = {};
|
|
@@ -232,7 +229,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
232
229
|
* Invite a user to the party (leader only)
|
|
233
230
|
* The party leader invites a user by ID. The target must be a friend of the leader or share at least one group with the leader. A PartyInvite record is created and an informational notification is sent. The invite is independent of notifications.
|
|
234
231
|
* @param {Object} opts Optional parameters
|
|
235
|
-
* @param {module:model/
|
|
232
|
+
* @param {module:model/InviteToGroupRequest} opts.inviteToGroupRequest Invite parameters
|
|
236
233
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
237
234
|
*/
|
|
238
235
|
}, {
|
|
@@ -247,14 +244,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
247
244
|
* Kick a member from the party (leader only)
|
|
248
245
|
* Remove a member from the party. Only the party leader can kick members.
|
|
249
246
|
* @param {Object} opts Optional parameters
|
|
250
|
-
* @param {module:model/
|
|
247
|
+
* @param {module:model/InviteToGroupRequest} [inviteToGroupRequest] Kick parameters
|
|
251
248
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
252
249
|
*/
|
|
253
250
|
}, {
|
|
254
251
|
key: "kickPartyMemberWithHttpInfo",
|
|
255
252
|
value: function kickPartyMemberWithHttpInfo(opts) {
|
|
256
253
|
opts = opts || {};
|
|
257
|
-
var postBody = opts['
|
|
254
|
+
var postBody = opts['inviteToGroupRequest'];
|
|
258
255
|
var pathParams = {};
|
|
259
256
|
var queryParams = {};
|
|
260
257
|
var headerParams = {};
|
|
@@ -270,7 +267,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
270
267
|
* Kick a member from the party (leader only)
|
|
271
268
|
* Remove a member from the party. Only the party leader can kick members.
|
|
272
269
|
* @param {Object} opts Optional parameters
|
|
273
|
-
* @param {module:model/
|
|
270
|
+
* @param {module:model/InviteToGroupRequest} opts.inviteToGroupRequest Kick parameters
|
|
274
271
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
275
272
|
*/
|
|
276
273
|
}, {
|
package/dist/api/UsersApi.js
CHANGED
|
@@ -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, 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.
|
|
25
|
+
* The version of the OpenAPI document: 1.0.990
|
|
26
26
|
*
|
|
27
27
|
*
|
|
28
28
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -154,7 +154,7 @@ var UsersApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
* Search users by id/
|
|
157
|
+
* Search users by id/display_name
|
|
158
158
|
* @param {Object} opts Optional parameters
|
|
159
159
|
* @param {String} [q]
|
|
160
160
|
* @param {Number} [page]
|
|
@@ -182,7 +182,7 @@ var UsersApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
|
-
* Search users by id/
|
|
185
|
+
* Search users by id/display_name
|
|
186
186
|
* @param {Object} opts Optional parameters
|
|
187
187
|
* @param {String} opts.q
|
|
188
188
|
* @param {Number} opts.page
|
package/dist/index.js
CHANGED
|
@@ -63,12 +63,6 @@ Object.defineProperty(exports, "AdminCreateNotificationRequest", {
|
|
|
63
63
|
return _AdminCreateNotificationRequest["default"];
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
Object.defineProperty(exports, "AdminDeleteChatConversation200Response", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function get() {
|
|
69
|
-
return _AdminDeleteChatConversation200Response["default"];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
66
|
Object.defineProperty(exports, "AdminEndLeaderboard200Response", {
|
|
73
67
|
enumerable: true,
|
|
74
68
|
get: function get() {
|
|
@@ -279,12 +273,6 @@ Object.defineProperty(exports, "AdminUpdateLobby200Response", {
|
|
|
279
273
|
return _AdminUpdateLobby200Response["default"];
|
|
280
274
|
}
|
|
281
275
|
});
|
|
282
|
-
Object.defineProperty(exports, "AdminUpdateLobbyRequest", {
|
|
283
|
-
enumerable: true,
|
|
284
|
-
get: function get() {
|
|
285
|
-
return _AdminUpdateLobbyRequest["default"];
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
276
|
Object.defineProperty(exports, "AdminUpdateUser200Response", {
|
|
289
277
|
enumerable: true,
|
|
290
278
|
get: function get() {
|
|
@@ -333,24 +321,12 @@ Object.defineProperty(exports, "CallHookRequest", {
|
|
|
333
321
|
return _CallHookRequest["default"];
|
|
334
322
|
}
|
|
335
323
|
});
|
|
336
|
-
Object.defineProperty(exports, "CancelGroupInvite200Response", {
|
|
337
|
-
enumerable: true,
|
|
338
|
-
get: function get() {
|
|
339
|
-
return _CancelGroupInvite200Response["default"];
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
324
|
Object.defineProperty(exports, "CancelJoinRequest200Response", {
|
|
343
325
|
enumerable: true,
|
|
344
326
|
get: function get() {
|
|
345
327
|
return _CancelJoinRequest200Response["default"];
|
|
346
328
|
}
|
|
347
329
|
});
|
|
348
|
-
Object.defineProperty(exports, "CancelPartyInviteRequest", {
|
|
349
|
-
enumerable: true,
|
|
350
|
-
get: function get() {
|
|
351
|
-
return _CancelPartyInviteRequest["default"];
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
330
|
Object.defineProperty(exports, "ChatApi", {
|
|
355
331
|
enumerable: true,
|
|
356
332
|
get: function get() {
|
|
@@ -363,12 +339,6 @@ Object.defineProperty(exports, "ChatUnreadCount200Response", {
|
|
|
363
339
|
return _ChatUnreadCount200Response["default"];
|
|
364
340
|
}
|
|
365
341
|
});
|
|
366
|
-
Object.defineProperty(exports, "CreateFriendRequestRequest", {
|
|
367
|
-
enumerable: true,
|
|
368
|
-
get: function get() {
|
|
369
|
-
return _CreateFriendRequestRequest["default"];
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
342
|
Object.defineProperty(exports, "CreateGroupRequest", {
|
|
373
343
|
enumerable: true,
|
|
374
344
|
get: function get() {
|
|
@@ -387,12 +357,6 @@ Object.defineProperty(exports, "CreatePartyRequest", {
|
|
|
387
357
|
return _CreatePartyRequest["default"];
|
|
388
358
|
}
|
|
389
359
|
});
|
|
390
|
-
Object.defineProperty(exports, "DeclinePartyInviteRequest", {
|
|
391
|
-
enumerable: true,
|
|
392
|
-
get: function get() {
|
|
393
|
-
return _DeclinePartyInviteRequest["default"];
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
360
|
Object.defineProperty(exports, "DeleteNotifications200Response", {
|
|
397
361
|
enumerable: true,
|
|
398
362
|
get: function get() {
|
|
@@ -405,12 +369,6 @@ Object.defineProperty(exports, "DeleteNotificationsRequest", {
|
|
|
405
369
|
return _DeleteNotificationsRequest["default"];
|
|
406
370
|
}
|
|
407
371
|
});
|
|
408
|
-
Object.defineProperty(exports, "DemoteGroupMemberRequest", {
|
|
409
|
-
enumerable: true,
|
|
410
|
-
get: function get() {
|
|
411
|
-
return _DemoteGroupMemberRequest["default"];
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
372
|
Object.defineProperty(exports, "DeviceLoginRequest", {
|
|
415
373
|
enumerable: true,
|
|
416
374
|
get: function get() {
|
|
@@ -459,12 +417,6 @@ Object.defineProperty(exports, "GetLobby200Response", {
|
|
|
459
417
|
return _GetLobby200Response["default"];
|
|
460
418
|
}
|
|
461
419
|
});
|
|
462
|
-
Object.defineProperty(exports, "GetLobby200ResponseMembersInner", {
|
|
463
|
-
enumerable: true,
|
|
464
|
-
get: function get() {
|
|
465
|
-
return _GetLobby200ResponseMembersInner["default"];
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
420
|
Object.defineProperty(exports, "GetMyRecord200Response", {
|
|
469
421
|
enumerable: true,
|
|
470
422
|
get: function get() {
|
|
@@ -507,42 +459,18 @@ Object.defineProperty(exports, "InviteToGroupRequest", {
|
|
|
507
459
|
return _InviteToGroupRequest["default"];
|
|
508
460
|
}
|
|
509
461
|
});
|
|
510
|
-
Object.defineProperty(exports, "InviteToPartyRequest", {
|
|
511
|
-
enumerable: true,
|
|
512
|
-
get: function get() {
|
|
513
|
-
return _InviteToPartyRequest["default"];
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
462
|
Object.defineProperty(exports, "KVApi", {
|
|
517
463
|
enumerable: true,
|
|
518
464
|
get: function get() {
|
|
519
465
|
return _KVApi["default"];
|
|
520
466
|
}
|
|
521
467
|
});
|
|
522
|
-
Object.defineProperty(exports, "KickGroupMemberRequest", {
|
|
523
|
-
enumerable: true,
|
|
524
|
-
get: function get() {
|
|
525
|
-
return _KickGroupMemberRequest["default"];
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
Object.defineProperty(exports, "KickUserRequest", {
|
|
529
|
-
enumerable: true,
|
|
530
|
-
get: function get() {
|
|
531
|
-
return _KickUserRequest["default"];
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
468
|
Object.defineProperty(exports, "LeaderboardsApi", {
|
|
535
469
|
enumerable: true,
|
|
536
470
|
get: function get() {
|
|
537
471
|
return _LeaderboardsApi["default"];
|
|
538
472
|
}
|
|
539
473
|
});
|
|
540
|
-
Object.defineProperty(exports, "LinkDeviceRequest", {
|
|
541
|
-
enumerable: true,
|
|
542
|
-
get: function get() {
|
|
543
|
-
return _LinkDeviceRequest["default"];
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
474
|
Object.defineProperty(exports, "ListBlockedFriends200Response", {
|
|
547
475
|
enumerable: true,
|
|
548
476
|
get: function get() {
|
|
@@ -603,18 +531,6 @@ Object.defineProperty(exports, "ListFriends200ResponseDataInner", {
|
|
|
603
531
|
return _ListFriends200ResponseDataInner["default"];
|
|
604
532
|
}
|
|
605
533
|
});
|
|
606
|
-
Object.defineProperty(exports, "ListGroupInvitations200Response", {
|
|
607
|
-
enumerable: true,
|
|
608
|
-
get: function get() {
|
|
609
|
-
return _ListGroupInvitations200Response["default"];
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
Object.defineProperty(exports, "ListGroupInvitations200ResponseDataInner", {
|
|
613
|
-
enumerable: true,
|
|
614
|
-
get: function get() {
|
|
615
|
-
return _ListGroupInvitations200ResponseDataInner["default"];
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
534
|
Object.defineProperty(exports, "ListGroupMembers200Response", {
|
|
619
535
|
enumerable: true,
|
|
620
536
|
get: function get() {
|
|
@@ -681,18 +597,6 @@ Object.defineProperty(exports, "ListMyGroups200ResponseDataInner", {
|
|
|
681
597
|
return _ListMyGroups200ResponseDataInner["default"];
|
|
682
598
|
}
|
|
683
599
|
});
|
|
684
|
-
Object.defineProperty(exports, "ListNotifications200Response", {
|
|
685
|
-
enumerable: true,
|
|
686
|
-
get: function get() {
|
|
687
|
-
return _ListNotifications200Response["default"];
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
Object.defineProperty(exports, "ListNotifications200ResponseDataInner", {
|
|
691
|
-
enumerable: true,
|
|
692
|
-
get: function get() {
|
|
693
|
-
return _ListNotifications200ResponseDataInner["default"];
|
|
694
|
-
}
|
|
695
|
-
});
|
|
696
600
|
Object.defineProperty(exports, "ListPartyInvitations200ResponseInner", {
|
|
697
601
|
enumerable: true,
|
|
698
602
|
get: function get() {
|
|
@@ -723,18 +627,6 @@ Object.defineProperty(exports, "LobbiesApi", {
|
|
|
723
627
|
return _LobbiesApi["default"];
|
|
724
628
|
}
|
|
725
629
|
});
|
|
726
|
-
Object.defineProperty(exports, "Login200Response", {
|
|
727
|
-
enumerable: true,
|
|
728
|
-
get: function get() {
|
|
729
|
-
return _Login200Response["default"];
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
Object.defineProperty(exports, "Login200ResponseData", {
|
|
733
|
-
enumerable: true,
|
|
734
|
-
get: function get() {
|
|
735
|
-
return _Login200ResponseData["default"];
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
630
|
Object.defineProperty(exports, "LoginRequest", {
|
|
739
631
|
enumerable: true,
|
|
740
632
|
get: function get() {
|
|
@@ -837,12 +729,6 @@ Object.defineProperty(exports, "PartyJoinLobbyRequest", {
|
|
|
837
729
|
return _PartyJoinLobbyRequest["default"];
|
|
838
730
|
}
|
|
839
731
|
});
|
|
840
|
-
Object.defineProperty(exports, "PromoteGroupMemberRequest", {
|
|
841
|
-
enumerable: true,
|
|
842
|
-
get: function get() {
|
|
843
|
-
return _PromoteGroupMemberRequest["default"];
|
|
844
|
-
}
|
|
845
|
-
});
|
|
846
732
|
Object.defineProperty(exports, "QuickJoinRequest", {
|
|
847
733
|
enumerable: true,
|
|
848
734
|
get: function get() {
|
|
@@ -983,7 +869,6 @@ var _AdminCreateKvEntryRequest = _interopRequireDefault(require("./model/AdminCr
|
|
|
983
869
|
var _AdminCreateLeaderboardRequest = _interopRequireDefault(require("./model/AdminCreateLeaderboardRequest"));
|
|
984
870
|
var _AdminCreateNotification400Response = _interopRequireDefault(require("./model/AdminCreateNotification400Response"));
|
|
985
871
|
var _AdminCreateNotificationRequest = _interopRequireDefault(require("./model/AdminCreateNotificationRequest"));
|
|
986
|
-
var _AdminDeleteChatConversation200Response = _interopRequireDefault(require("./model/AdminDeleteChatConversation200Response"));
|
|
987
872
|
var _AdminEndLeaderboard200Response = _interopRequireDefault(require("./model/AdminEndLeaderboard200Response"));
|
|
988
873
|
var _AdminEndLeaderboard200ResponseData = _interopRequireDefault(require("./model/AdminEndLeaderboard200ResponseData"));
|
|
989
874
|
var _AdminIncrementAchievementRequest = _interopRequireDefault(require("./model/AdminIncrementAchievementRequest"));
|
|
@@ -1013,24 +898,18 @@ var _AdminUpdateKvEntryRequest = _interopRequireDefault(require("./model/AdminUp
|
|
|
1013
898
|
var _AdminUpdateLeaderboardRecordRequest = _interopRequireDefault(require("./model/AdminUpdateLeaderboardRecordRequest"));
|
|
1014
899
|
var _AdminUpdateLeaderboardRequest = _interopRequireDefault(require("./model/AdminUpdateLeaderboardRequest"));
|
|
1015
900
|
var _AdminUpdateLobby200Response = _interopRequireDefault(require("./model/AdminUpdateLobby200Response"));
|
|
1016
|
-
var _AdminUpdateLobbyRequest = _interopRequireDefault(require("./model/AdminUpdateLobbyRequest"));
|
|
1017
901
|
var _AdminUpdateUser200Response = _interopRequireDefault(require("./model/AdminUpdateUser200Response"));
|
|
1018
902
|
var _AdminUpdateUser200ResponseData = _interopRequireDefault(require("./model/AdminUpdateUser200ResponseData"));
|
|
1019
903
|
var _AdminUpdateUserRequest = _interopRequireDefault(require("./model/AdminUpdateUserRequest"));
|
|
1020
904
|
var _CallHook200Response = _interopRequireDefault(require("./model/CallHook200Response"));
|
|
1021
905
|
var _CallHookRequest = _interopRequireDefault(require("./model/CallHookRequest"));
|
|
1022
|
-
var _CancelGroupInvite200Response = _interopRequireDefault(require("./model/CancelGroupInvite200Response"));
|
|
1023
906
|
var _CancelJoinRequest200Response = _interopRequireDefault(require("./model/CancelJoinRequest200Response"));
|
|
1024
|
-
var _CancelPartyInviteRequest = _interopRequireDefault(require("./model/CancelPartyInviteRequest"));
|
|
1025
907
|
var _ChatUnreadCount200Response = _interopRequireDefault(require("./model/ChatUnreadCount200Response"));
|
|
1026
|
-
var _CreateFriendRequestRequest = _interopRequireDefault(require("./model/CreateFriendRequestRequest"));
|
|
1027
908
|
var _CreateGroupRequest = _interopRequireDefault(require("./model/CreateGroupRequest"));
|
|
1028
909
|
var _CreateLobbyRequest = _interopRequireDefault(require("./model/CreateLobbyRequest"));
|
|
1029
910
|
var _CreatePartyRequest = _interopRequireDefault(require("./model/CreatePartyRequest"));
|
|
1030
|
-
var _DeclinePartyInviteRequest = _interopRequireDefault(require("./model/DeclinePartyInviteRequest"));
|
|
1031
911
|
var _DeleteNotifications200Response = _interopRequireDefault(require("./model/DeleteNotifications200Response"));
|
|
1032
912
|
var _DeleteNotificationsRequest = _interopRequireDefault(require("./model/DeleteNotificationsRequest"));
|
|
1033
|
-
var _DemoteGroupMemberRequest = _interopRequireDefault(require("./model/DemoteGroupMemberRequest"));
|
|
1034
913
|
var _DeviceLoginRequest = _interopRequireDefault(require("./model/DeviceLoginRequest"));
|
|
1035
914
|
var _ErrorResponse = _interopRequireDefault(require("./model/ErrorResponse"));
|
|
1036
915
|
var _GetChatMessage200Response = _interopRequireDefault(require("./model/GetChatMessage200Response"));
|
|
@@ -1038,15 +917,10 @@ var _GetCurrentUser200Response = _interopRequireDefault(require("./model/GetCurr
|
|
|
1038
917
|
var _GetCurrentUser200ResponseLinkedProviders = _interopRequireDefault(require("./model/GetCurrentUser200ResponseLinkedProviders"));
|
|
1039
918
|
var _GetKv200Response = _interopRequireDefault(require("./model/GetKv200Response"));
|
|
1040
919
|
var _GetLobby200Response = _interopRequireDefault(require("./model/GetLobby200Response"));
|
|
1041
|
-
var _GetLobby200ResponseMembersInner = _interopRequireDefault(require("./model/GetLobby200ResponseMembersInner"));
|
|
1042
920
|
var _GetMyRecord200Response = _interopRequireDefault(require("./model/GetMyRecord200Response"));
|
|
1043
921
|
var _HealthResponse = _interopRequireDefault(require("./model/HealthResponse"));
|
|
1044
922
|
var _InviteToGroup200Response = _interopRequireDefault(require("./model/InviteToGroup200Response"));
|
|
1045
923
|
var _InviteToGroupRequest = _interopRequireDefault(require("./model/InviteToGroupRequest"));
|
|
1046
|
-
var _InviteToPartyRequest = _interopRequireDefault(require("./model/InviteToPartyRequest"));
|
|
1047
|
-
var _KickGroupMemberRequest = _interopRequireDefault(require("./model/KickGroupMemberRequest"));
|
|
1048
|
-
var _KickUserRequest = _interopRequireDefault(require("./model/KickUserRequest"));
|
|
1049
|
-
var _LinkDeviceRequest = _interopRequireDefault(require("./model/LinkDeviceRequest"));
|
|
1050
924
|
var _ListBlockedFriends200Response = _interopRequireDefault(require("./model/ListBlockedFriends200Response"));
|
|
1051
925
|
var _ListBlockedFriends200ResponseDataInner = _interopRequireDefault(require("./model/ListBlockedFriends200ResponseDataInner"));
|
|
1052
926
|
var _ListBlockedFriends200ResponseDataInnerRequester = _interopRequireDefault(require("./model/ListBlockedFriends200ResponseDataInnerRequester"));
|
|
@@ -1057,8 +931,6 @@ var _ListFriendRequests200ResponseIncomingInnerRequester = _interopRequireDefaul
|
|
|
1057
931
|
var _ListFriendRequests200ResponseMeta = _interopRequireDefault(require("./model/ListFriendRequests200ResponseMeta"));
|
|
1058
932
|
var _ListFriends200Response = _interopRequireDefault(require("./model/ListFriends200Response"));
|
|
1059
933
|
var _ListFriends200ResponseDataInner = _interopRequireDefault(require("./model/ListFriends200ResponseDataInner"));
|
|
1060
|
-
var _ListGroupInvitations200Response = _interopRequireDefault(require("./model/ListGroupInvitations200Response"));
|
|
1061
|
-
var _ListGroupInvitations200ResponseDataInner = _interopRequireDefault(require("./model/ListGroupInvitations200ResponseDataInner"));
|
|
1062
934
|
var _ListGroupMembers200Response = _interopRequireDefault(require("./model/ListGroupMembers200Response"));
|
|
1063
935
|
var _ListGroupMembers200ResponseDataInner = _interopRequireDefault(require("./model/ListGroupMembers200ResponseDataInner"));
|
|
1064
936
|
var _ListJoinRequests200Response = _interopRequireDefault(require("./model/ListJoinRequests200Response"));
|
|
@@ -1070,14 +942,10 @@ var _ListLobbies200Response = _interopRequireDefault(require("./model/ListLobbie
|
|
|
1070
942
|
var _ListLobbies200ResponseDataInner = _interopRequireDefault(require("./model/ListLobbies200ResponseDataInner"));
|
|
1071
943
|
var _ListMyGroups200Response = _interopRequireDefault(require("./model/ListMyGroups200Response"));
|
|
1072
944
|
var _ListMyGroups200ResponseDataInner = _interopRequireDefault(require("./model/ListMyGroups200ResponseDataInner"));
|
|
1073
|
-
var _ListNotifications200Response = _interopRequireDefault(require("./model/ListNotifications200Response"));
|
|
1074
|
-
var _ListNotifications200ResponseDataInner = _interopRequireDefault(require("./model/ListNotifications200ResponseDataInner"));
|
|
1075
945
|
var _ListPartyInvitations200ResponseInner = _interopRequireDefault(require("./model/ListPartyInvitations200ResponseInner"));
|
|
1076
946
|
var _ListRecordsAroundUser200Response = _interopRequireDefault(require("./model/ListRecordsAroundUser200Response"));
|
|
1077
947
|
var _ListSentInvitations200Response = _interopRequireDefault(require("./model/ListSentInvitations200Response"));
|
|
1078
948
|
var _ListSentInvitations200ResponseDataInner = _interopRequireDefault(require("./model/ListSentInvitations200ResponseDataInner"));
|
|
1079
|
-
var _Login200Response = _interopRequireDefault(require("./model/Login200Response"));
|
|
1080
|
-
var _Login200ResponseData = _interopRequireDefault(require("./model/Login200ResponseData"));
|
|
1081
949
|
var _LoginRequest = _interopRequireDefault(require("./model/LoginRequest"));
|
|
1082
950
|
var _MarkChatReadRequest = _interopRequireDefault(require("./model/MarkChatReadRequest"));
|
|
1083
951
|
var _NotifyGroup200Response = _interopRequireDefault(require("./model/NotifyGroup200Response"));
|
|
@@ -1093,7 +961,6 @@ var _OauthRequest200Response = _interopRequireDefault(require("./model/OauthRequ
|
|
|
1093
961
|
var _OauthSessionStatus404Response = _interopRequireDefault(require("./model/OauthSessionStatus404Response"));
|
|
1094
962
|
var _PartyCreateLobbyRequest = _interopRequireDefault(require("./model/PartyCreateLobbyRequest"));
|
|
1095
963
|
var _PartyJoinLobbyRequest = _interopRequireDefault(require("./model/PartyJoinLobbyRequest"));
|
|
1096
|
-
var _PromoteGroupMemberRequest = _interopRequireDefault(require("./model/PromoteGroupMemberRequest"));
|
|
1097
964
|
var _QuickJoinRequest = _interopRequireDefault(require("./model/QuickJoinRequest"));
|
|
1098
965
|
var _RefreshToken200Response = _interopRequireDefault(require("./model/RefreshToken200Response"));
|
|
1099
966
|
var _RefreshToken200ResponseData = _interopRequireDefault(require("./model/RefreshToken200ResponseData"));
|
|
@@ -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, 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.
|
|
21
|
+
* The version of the OpenAPI document: 1.0.990
|
|
22
22
|
*
|
|
23
23
|
*
|
|
24
24
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|