@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.
- package/README.md +24 -24
- package/dist/ApiClient.js +1 -1
- package/dist/api/AchievementsApi.js +15 -15
- package/dist/api/AdminAchievementsApi.js +16 -16
- package/dist/api/AdminChatApi.js +6 -6
- package/dist/api/AdminGroupsApi.js +2 -2
- package/dist/api/AdminKVApi.js +19 -19
- package/dist/api/AdminLeaderboardsApi.js +19 -19
- package/dist/api/AdminLobbiesApi.js +2 -2
- package/dist/api/AdminNotificationsApi.js +2 -2
- package/dist/api/AdminSessionsApi.js +2 -2
- package/dist/api/AdminUsersApi.js +2 -2
- package/dist/api/AuthenticationApi.js +2 -2
- package/dist/api/ChatApi.js +11 -11
- package/dist/api/FriendsApi.js +7 -7
- package/dist/api/GroupsApi.js +41 -41
- package/dist/api/HealthApi.js +1 -1
- package/dist/api/HooksApi.js +2 -2
- package/dist/api/KVApi.js +2 -2
- package/dist/api/LeaderboardsApi.js +6 -6
- package/dist/api/LobbiesApi.js +6 -6
- package/dist/api/NotificationsApi.js +6 -6
- package/dist/api/PartiesApi.js +25 -25
- package/dist/api/PaymentsApi.js +2 -2
- package/dist/api/UsersApi.js +3 -3
- package/dist/index.js +133 -133
- package/dist/model/{ShowParty200Response.js → AcceptPartyInvite200Response.js} +27 -27
- package/dist/model/{ShowParty200ResponseMembersInner.js → AcceptPartyInvite200ResponseMembersInner.js} +23 -23
- package/dist/model/AcceptPartyInviteRequest.js +1 -1
- package/dist/model/AdminCreateAchievementRequest.js +1 -1
- package/dist/model/{AdminCreateKvEntry200Response.js → AdminCreateLeaderboard200Response.js} +22 -22
- package/dist/model/{AdminEndLeaderboard200ResponseData.js → AdminCreateLeaderboard200ResponseData.js} +32 -32
- package/dist/model/AdminCreateLeaderboardRequest.js +1 -1
- package/dist/model/AdminCreateNotificationRequest.js +1 -1
- package/dist/model/{DeleteNotifications200Response.js → AdminDeleteChatConversation200Response.js} +18 -19
- package/dist/model/{AdminUnlockAchievementRequest.js → AdminGrantAchievementRequest.js} +21 -21
- package/dist/model/AdminIncrementAchievementRequest.js +1 -1
- package/dist/model/AdminListAchievements200Response.js +5 -5
- package/dist/model/{AdminUpdateAchievement200Response.js → AdminListAchievements200ResponseDataInner.js} +28 -28
- package/dist/model/AdminListChatMessages200Response.js +5 -5
- package/dist/model/AdminListChatMessages200ResponseDataInner.js +1 -1
- package/dist/model/AdminListGroups200Response.js +5 -5
- package/dist/model/AdminListKvEntries200Response.js +9 -9
- package/dist/model/AdminListLobbies200Response.js +5 -5
- package/dist/model/AdminListLobbies200ResponseDataInner.js +1 -1
- package/dist/model/AdminListNotifications200Response.js +5 -5
- package/dist/model/AdminListNotifications200ResponseDataInner.js +1 -1
- package/dist/model/AdminListSessions200Response.js +5 -5
- package/dist/model/AdminListSessions200ResponseDataInner.js +1 -1
- package/dist/model/AdminRevokeAchievementRequest.js +1 -1
- package/dist/model/AdminSubmitLeaderboardScoreRequest.js +1 -1
- package/dist/model/AdminUpdateAchievementRequest.js +1 -1
- package/dist/model/AdminUpdateGroup200Response.js +1 -1
- package/dist/model/AdminUpdateGroupRequest.js +1 -1
- package/dist/model/AdminUpdateKvEntryRequest.js +1 -1
- package/dist/model/{AdminSubmitLeaderboardScore200Response.js → AdminUpdateLeaderboardRecord200Response.js} +22 -22
- package/dist/model/{AdminSubmitLeaderboardScore200ResponseData.js → AdminUpdateLeaderboardRecord200ResponseData.js} +26 -26
- 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/{AdminEndLeaderboard200Response.js → AdminUpsertKv200Response.js} +22 -22
- package/dist/model/{AdminListKvEntries200ResponseDataInner.js → AdminUpsertKv200ResponseData.js} +25 -25
- package/dist/model/{AdminCreateKvEntryRequest.js → AdminUpsertKvRequest.js} +24 -24
- package/dist/model/{ListGroupMembers200ResponseDataInner.js → ApproveJoinRequest200Response.js} +28 -28
- 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/{InviteToGroup200Response.js → DeclineGroupInvite200Response.js} +18 -19
- package/dist/model/DeleteNotificationsRequest.js +1 -1
- package/dist/model/DeviceLoginRequest.js +1 -1
- package/dist/model/ErrorResponse.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 +5 -5
- package/dist/model/{ListLeaderboardRecords200ResponseDataInner.js → GetMyRecord200ResponseData.js} +23 -23
- package/dist/model/HealthResponse.js +1 -1
- package/dist/model/{InviteToGroupRequest.js → InviteToPartyRequest.js} +22 -22
- package/dist/model/ListBlockedFriends200Response.js +5 -5
- package/dist/model/ListBlockedFriends200ResponseDataInner.js +1 -1
- package/dist/model/ListBlockedFriends200ResponseDataInnerRequester.js +1 -1
- package/dist/model/ListChatMessages200Response.js +5 -5
- package/dist/model/{GetChatMessage200Response.js → ListChatMessages200ResponseDataInner.js} +28 -28
- 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 +5 -5
- package/dist/model/ListFriends200ResponseDataInner.js +1 -1
- package/dist/model/{AdminListNotifications200ResponseMeta.js → ListFriends200ResponseMeta.js} +23 -23
- package/dist/model/ListGroupMembers200Response.js +9 -9
- package/dist/model/ListJoinRequests200Response.js +5 -5
- package/dist/model/ListLeaderboardRecords200Response.js +9 -9
- package/dist/model/ListLeaderboards200Response.js +9 -9
- package/dist/model/ListLobbies200Response.js +5 -5
- package/dist/model/ListLobbies200ResponseDataInner.js +1 -1
- package/dist/model/ListMyGroups200Response.js +5 -5
- package/dist/model/ListMyGroups200ResponseDataInner.js +1 -1
- package/dist/model/ListPartyInvitations200ResponseInner.js +1 -1
- package/dist/model/ListRecordsAroundUser200Response.js +5 -5
- package/dist/model/ListSentInvitations200Response.js +5 -5
- package/dist/model/ListSentInvitations200ResponseDataInner.js +1 -1
- package/dist/model/LoginRequest.js +1 -1
- package/dist/model/MarkChatReadRequest.js +1 -1
- package/dist/model/{UserAchievements200Response.js → MyAchievements200Response.js} +27 -27
- package/dist/model/{UserAchievements200ResponseDataInner.js → MyAchievements200ResponseDataInner.js} +28 -28
- 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/{AdminCreateNotification400Response.js → PaymentsEntitlements401Response.js} +18 -18
- package/dist/model/PaymentsSteamCheckoutRequest.js +1 -1
- package/dist/model/PaymentsSteamFinalizeRequest.js +1 -1
- package/dist/model/PaymentsStripeCheckoutRequest.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 +4 -4
- package/dist/model/{ListLeaderboards200ResponseDataInner.js → ResolveLeaderboardSlugs200ResponseDataValue.js} +33 -33
- package/dist/model/ResolveLeaderboardSlugsRequest.js +1 -1
- package/dist/model/SearchUsers200Response.js +5 -5
- package/dist/model/SearchUsers200ResponseDataInner.js +1 -1
- package/dist/model/SendChatMessageRequest.js +1 -1
- package/dist/model/SendNotificationRequest.js +1 -1
- package/dist/model/UpdateChatMessageRequest.js +1 -1
- package/dist/model/{UpdateCurrentUserPassword400Response.js → UpdateCurrentUserDisplayName400Response.js} +19 -19
- package/dist/model/UpdateCurrentUserDisplayNameRequest.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/package.json +1 -1
package/dist/api/KVApi.js
CHANGED
|
@@ -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 _GetKv200Response = _interopRequireDefault(require("../model/GetKv200Response"));
|
|
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.
|
|
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,13 +5,13 @@ 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 _GetMyRecord200Response = _interopRequireDefault(require("../model/GetMyRecord200Response"));
|
|
10
9
|
var _ListLeaderboardRecords200Response = _interopRequireDefault(require("../model/ListLeaderboardRecords200Response"));
|
|
11
10
|
var _ListLeaderboards200Response = _interopRequireDefault(require("../model/ListLeaderboards200Response"));
|
|
12
|
-
var _ListLeaderboards200ResponseDataInner = _interopRequireDefault(require("../model/ListLeaderboards200ResponseDataInner"));
|
|
13
11
|
var _ListRecordsAroundUser200Response = _interopRequireDefault(require("../model/ListRecordsAroundUser200Response"));
|
|
12
|
+
var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
|
|
14
13
|
var _ResolveLeaderboardSlugs200Response = _interopRequireDefault(require("../model/ResolveLeaderboardSlugs200Response"));
|
|
14
|
+
var _ResolveLeaderboardSlugs200ResponseDataValue = _interopRequireDefault(require("../model/ResolveLeaderboardSlugs200ResponseDataValue"));
|
|
15
15
|
var _ResolveLeaderboardSlugsRequest = _interopRequireDefault(require("../model/ResolveLeaderboardSlugsRequest"));
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
17
|
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); }
|
|
@@ -23,7 +23,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
23
23
|
* Game Server API
|
|
24
24
|
* 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 })) ```
|
|
25
25
|
*
|
|
26
|
-
* The version of the OpenAPI document: 1.0.
|
|
26
|
+
* The version of the OpenAPI document: 1.0.1004
|
|
27
27
|
*
|
|
28
28
|
*
|
|
29
29
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -53,7 +53,7 @@ var LeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
53
53
|
* Get a leaderboard by ID
|
|
54
54
|
* Return details for a specific leaderboard by its integer ID.
|
|
55
55
|
* @param {Number} id Leaderboard ID
|
|
56
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
56
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ResolveLeaderboardSlugs200ResponseDataValue} and HTTP response
|
|
57
57
|
*/
|
|
58
58
|
return _createClass(LeaderboardsApi, [{
|
|
59
59
|
key: "getLeaderboardWithHttpInfo",
|
|
@@ -72,7 +72,7 @@ var LeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
72
72
|
var authNames = [];
|
|
73
73
|
var contentTypes = [];
|
|
74
74
|
var accepts = ['application/json'];
|
|
75
|
-
var returnType =
|
|
75
|
+
var returnType = _ResolveLeaderboardSlugs200ResponseDataValue["default"];
|
|
76
76
|
return this.apiClient.callApi('/api/v1/leaderboards/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -80,7 +80,7 @@ var LeaderboardsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
80
80
|
* Get a leaderboard by ID
|
|
81
81
|
* Return details for a specific leaderboard by its integer ID.
|
|
82
82
|
* @param {Number} id Leaderboard ID
|
|
83
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
83
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ResolveLeaderboardSlugs200ResponseDataValue}
|
|
84
84
|
*/
|
|
85
85
|
}, {
|
|
86
86
|
key: "getLeaderboard",
|
package/dist/api/LobbiesApi.js
CHANGED
|
@@ -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 _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
|
|
9
8
|
var _CreateLobbyRequest = _interopRequireDefault(require("../model/CreateLobbyRequest"));
|
|
10
9
|
var _GetLobby200Response = _interopRequireDefault(require("../model/GetLobby200Response"));
|
|
11
|
-
var
|
|
10
|
+
var _InviteToPartyRequest = _interopRequireDefault(require("../model/InviteToPartyRequest"));
|
|
12
11
|
var _ListLobbies200Response = _interopRequireDefault(require("../model/ListLobbies200Response"));
|
|
13
12
|
var _ListLobbies200ResponseDataInner = _interopRequireDefault(require("../model/ListLobbies200ResponseDataInner"));
|
|
14
13
|
var _PartyJoinLobbyRequest = _interopRequireDefault(require("../model/PartyJoinLobbyRequest"));
|
|
14
|
+
var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
|
|
15
15
|
var _QuickJoinRequest = _interopRequireDefault(require("../model/QuickJoinRequest"));
|
|
16
16
|
var _UpdateLobbyRequest = _interopRequireDefault(require("../model/UpdateLobbyRequest"));
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -24,7 +24,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
24
|
* Game Server API
|
|
25
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, 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 })) ```
|
|
26
26
|
*
|
|
27
|
-
* The version of the OpenAPI document: 1.0.
|
|
27
|
+
* The version of the OpenAPI document: 1.0.1004
|
|
28
28
|
*
|
|
29
29
|
*
|
|
30
30
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -179,14 +179,14 @@ var LobbiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
179
179
|
* Kick a user from the lobby (host only)
|
|
180
180
|
* Remove a user from the lobby. Only the host can kick users via the API (returns 403 if not host).
|
|
181
181
|
* @param {Object} opts Optional parameters
|
|
182
|
-
* @param {module:model/
|
|
182
|
+
* @param {module:model/InviteToPartyRequest} [inviteToPartyRequest] Kick parameters
|
|
183
183
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
184
184
|
*/
|
|
185
185
|
}, {
|
|
186
186
|
key: "kickUserWithHttpInfo",
|
|
187
187
|
value: function kickUserWithHttpInfo(opts) {
|
|
188
188
|
opts = opts || {};
|
|
189
|
-
var postBody = opts['
|
|
189
|
+
var postBody = opts['inviteToPartyRequest'];
|
|
190
190
|
var pathParams = {};
|
|
191
191
|
var queryParams = {};
|
|
192
192
|
var headerParams = {};
|
|
@@ -202,7 +202,7 @@ var LobbiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
202
202
|
* Kick a user from the lobby (host only)
|
|
203
203
|
* Remove a user from the lobby. Only the host can kick users via the API (returns 403 if not host).
|
|
204
204
|
* @param {Object} opts Optional parameters
|
|
205
|
-
* @param {module:model/
|
|
205
|
+
* @param {module:model/InviteToPartyRequest} opts.inviteToPartyRequest Kick parameters
|
|
206
206
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
207
207
|
*/
|
|
208
208
|
}, {
|
|
@@ -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
|
|
8
|
+
var _AdminDeleteChatConversation200Response = _interopRequireDefault(require("../model/AdminDeleteChatConversation200Response"));
|
|
9
9
|
var _AdminListNotifications200Response = _interopRequireDefault(require("../model/AdminListNotifications200Response"));
|
|
10
10
|
var _AdminListNotifications200ResponseDataInner = _interopRequireDefault(require("../model/AdminListNotifications200ResponseDataInner"));
|
|
11
|
-
var _DeleteNotifications200Response = _interopRequireDefault(require("../model/DeleteNotifications200Response"));
|
|
12
11
|
var _DeleteNotificationsRequest = _interopRequireDefault(require("../model/DeleteNotificationsRequest"));
|
|
12
|
+
var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
|
|
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, 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 })) ```
|
|
23
23
|
*
|
|
24
|
-
* The version of the OpenAPI document: 1.0.
|
|
24
|
+
* The version of the OpenAPI document: 1.0.1004
|
|
25
25
|
*
|
|
26
26
|
*
|
|
27
27
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -52,7 +52,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
52
52
|
* Delete one or more notifications belonging to the authenticated user. Pass an array of notification IDs.
|
|
53
53
|
* @param {Object} opts Optional parameters
|
|
54
54
|
* @param {module:model/DeleteNotificationsRequest} [deleteNotificationsRequest] Notification IDs to delete
|
|
55
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
55
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AdminDeleteChatConversation200Response} and HTTP response
|
|
56
56
|
*/
|
|
57
57
|
return _createClass(NotificationsApi, [{
|
|
58
58
|
key: "deleteNotificationsWithHttpInfo",
|
|
@@ -66,7 +66,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
66
66
|
var authNames = ['authorization'];
|
|
67
67
|
var contentTypes = ['application/json'];
|
|
68
68
|
var accepts = ['application/json'];
|
|
69
|
-
var returnType =
|
|
69
|
+
var returnType = _AdminDeleteChatConversation200Response["default"];
|
|
70
70
|
return this.apiClient.callApi('/api/v1/notifications', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -75,7 +75,7 @@ var NotificationsApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
75
75
|
* Delete one or more notifications belonging to the authenticated user. Pass an array of notification IDs.
|
|
76
76
|
* @param {Object} opts Optional parameters
|
|
77
77
|
* @param {module:model/DeleteNotificationsRequest} opts.deleteNotificationsRequest Notification IDs to delete
|
|
78
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
78
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AdminDeleteChatConversation200Response}
|
|
79
79
|
*/
|
|
80
80
|
}, {
|
|
81
81
|
key: "deleteNotifications",
|
package/dist/api/PartiesApi.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
|
|
8
|
+
var _AcceptPartyInvite200Response = _interopRequireDefault(require("../model/AcceptPartyInvite200Response"));
|
|
8
9
|
var _AcceptPartyInviteRequest = _interopRequireDefault(require("../model/AcceptPartyInviteRequest"));
|
|
9
|
-
var _AdminCreateNotification400Response = _interopRequireDefault(require("../model/AdminCreateNotification400Response"));
|
|
10
10
|
var _CreatePartyRequest = _interopRequireDefault(require("../model/CreatePartyRequest"));
|
|
11
|
-
var
|
|
11
|
+
var _InviteToPartyRequest = _interopRequireDefault(require("../model/InviteToPartyRequest"));
|
|
12
12
|
var _ListPartyInvitations200ResponseInner = _interopRequireDefault(require("../model/ListPartyInvitations200ResponseInner"));
|
|
13
13
|
var _PartyCreateLobbyRequest = _interopRequireDefault(require("../model/PartyCreateLobbyRequest"));
|
|
14
14
|
var _PartyJoinLobbyRequest = _interopRequireDefault(require("../model/PartyJoinLobbyRequest"));
|
|
15
|
-
var
|
|
15
|
+
var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
|
|
16
16
|
var _UpdatePartyRequest = _interopRequireDefault(require("../model/UpdatePartyRequest"));
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
18
|
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); }
|
|
@@ -24,7 +24,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
24
|
* Game Server API
|
|
25
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, 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 })) ```
|
|
26
26
|
*
|
|
27
|
-
* The version of the OpenAPI document: 1.0.
|
|
27
|
+
* The version of the OpenAPI document: 1.0.1004
|
|
28
28
|
*
|
|
29
29
|
*
|
|
30
30
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -55,7 +55,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
55
55
|
* Accept a pending party invite. The user joins the party if there is space. The PartyInvite record is marked as accepted.
|
|
56
56
|
* @param {Object} opts Optional parameters
|
|
57
57
|
* @param {module:model/AcceptPartyInviteRequest} [acceptPartyInviteRequest] Accept parameters
|
|
58
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
58
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AcceptPartyInvite200Response} and HTTP response
|
|
59
59
|
*/
|
|
60
60
|
return _createClass(PartiesApi, [{
|
|
61
61
|
key: "acceptPartyInviteWithHttpInfo",
|
|
@@ -69,7 +69,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
69
69
|
var authNames = ['authorization'];
|
|
70
70
|
var contentTypes = ['application/json'];
|
|
71
71
|
var accepts = ['application/json'];
|
|
72
|
-
var returnType =
|
|
72
|
+
var returnType = _AcceptPartyInvite200Response["default"];
|
|
73
73
|
return this.apiClient.callApi('/api/v1/parties/invite/accept', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -78,7 +78,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
78
78
|
* Accept a pending party invite. The user joins the party if there is space. The PartyInvite record is marked as accepted.
|
|
79
79
|
* @param {Object} opts Optional parameters
|
|
80
80
|
* @param {module:model/AcceptPartyInviteRequest} opts.acceptPartyInviteRequest Accept parameters
|
|
81
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
81
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AcceptPartyInvite200Response}
|
|
82
82
|
*/
|
|
83
83
|
}, {
|
|
84
84
|
key: "acceptPartyInvite",
|
|
@@ -92,14 +92,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
92
92
|
* Cancel a pending party invite (leader only)
|
|
93
93
|
* Cancel an outstanding invite sent to a user. Only the leader can cancel.
|
|
94
94
|
* @param {Object} opts Optional parameters
|
|
95
|
-
* @param {module:model/
|
|
95
|
+
* @param {module:model/InviteToPartyRequest} [inviteToPartyRequest] Cancel parameters
|
|
96
96
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
97
97
|
*/
|
|
98
98
|
}, {
|
|
99
99
|
key: "cancelPartyInviteWithHttpInfo",
|
|
100
100
|
value: function cancelPartyInviteWithHttpInfo(opts) {
|
|
101
101
|
opts = opts || {};
|
|
102
|
-
var postBody = opts['
|
|
102
|
+
var postBody = opts['inviteToPartyRequest'];
|
|
103
103
|
var pathParams = {};
|
|
104
104
|
var queryParams = {};
|
|
105
105
|
var headerParams = {};
|
|
@@ -115,7 +115,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
115
115
|
* Cancel a pending party invite (leader only)
|
|
116
116
|
* Cancel an outstanding invite sent to a user. Only the leader can cancel.
|
|
117
117
|
* @param {Object} opts Optional parameters
|
|
118
|
-
* @param {module:model/
|
|
118
|
+
* @param {module:model/InviteToPartyRequest} opts.inviteToPartyRequest Cancel parameters
|
|
119
119
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
120
120
|
*/
|
|
121
121
|
}, {
|
|
@@ -131,7 +131,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
131
131
|
* Create a new party. The authenticated user becomes the leader and first member. Cannot create a party while already in a party.
|
|
132
132
|
* @param {Object} opts Optional parameters
|
|
133
133
|
* @param {module:model/CreatePartyRequest} [createPartyRequest] Party creation parameters
|
|
134
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
134
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AcceptPartyInvite200Response} and HTTP response
|
|
135
135
|
*/
|
|
136
136
|
}, {
|
|
137
137
|
key: "createPartyWithHttpInfo",
|
|
@@ -145,7 +145,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
145
145
|
var authNames = ['authorization'];
|
|
146
146
|
var contentTypes = ['application/json'];
|
|
147
147
|
var accepts = ['application/json'];
|
|
148
|
-
var returnType =
|
|
148
|
+
var returnType = _AcceptPartyInvite200Response["default"];
|
|
149
149
|
return this.apiClient.callApi('/api/v1/parties', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -154,7 +154,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
154
154
|
* Create a new party. The authenticated user becomes the leader and first member. Cannot create a party while already in a party.
|
|
155
155
|
* @param {Object} opts Optional parameters
|
|
156
156
|
* @param {module:model/CreatePartyRequest} opts.createPartyRequest Party creation parameters
|
|
157
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
157
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AcceptPartyInvite200Response}
|
|
158
158
|
*/
|
|
159
159
|
}, {
|
|
160
160
|
key: "createParty",
|
|
@@ -206,14 +206,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
206
206
|
* Invite a user to the party (leader only)
|
|
207
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.
|
|
208
208
|
* @param {Object} opts Optional parameters
|
|
209
|
-
* @param {module:model/
|
|
209
|
+
* @param {module:model/InviteToPartyRequest} [inviteToPartyRequest] Invite parameters
|
|
210
210
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
211
211
|
*/
|
|
212
212
|
}, {
|
|
213
213
|
key: "inviteToPartyWithHttpInfo",
|
|
214
214
|
value: function inviteToPartyWithHttpInfo(opts) {
|
|
215
215
|
opts = opts || {};
|
|
216
|
-
var postBody = opts['
|
|
216
|
+
var postBody = opts['inviteToPartyRequest'];
|
|
217
217
|
var pathParams = {};
|
|
218
218
|
var queryParams = {};
|
|
219
219
|
var headerParams = {};
|
|
@@ -229,7 +229,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
229
229
|
* Invite a user to the party (leader only)
|
|
230
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.
|
|
231
231
|
* @param {Object} opts Optional parameters
|
|
232
|
-
* @param {module:model/
|
|
232
|
+
* @param {module:model/InviteToPartyRequest} opts.inviteToPartyRequest Invite parameters
|
|
233
233
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
234
234
|
*/
|
|
235
235
|
}, {
|
|
@@ -244,14 +244,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
244
244
|
* Kick a member from the party (leader only)
|
|
245
245
|
* Remove a member from the party. Only the party leader can kick members.
|
|
246
246
|
* @param {Object} opts Optional parameters
|
|
247
|
-
* @param {module:model/
|
|
247
|
+
* @param {module:model/InviteToPartyRequest} [inviteToPartyRequest] Kick parameters
|
|
248
248
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Object} and HTTP response
|
|
249
249
|
*/
|
|
250
250
|
}, {
|
|
251
251
|
key: "kickPartyMemberWithHttpInfo",
|
|
252
252
|
value: function kickPartyMemberWithHttpInfo(opts) {
|
|
253
253
|
opts = opts || {};
|
|
254
|
-
var postBody = opts['
|
|
254
|
+
var postBody = opts['inviteToPartyRequest'];
|
|
255
255
|
var pathParams = {};
|
|
256
256
|
var queryParams = {};
|
|
257
257
|
var headerParams = {};
|
|
@@ -267,7 +267,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
267
267
|
* Kick a member from the party (leader only)
|
|
268
268
|
* Remove a member from the party. Only the party leader can kick members.
|
|
269
269
|
* @param {Object} opts Optional parameters
|
|
270
|
-
* @param {module:model/
|
|
270
|
+
* @param {module:model/InviteToPartyRequest} opts.inviteToPartyRequest Kick parameters
|
|
271
271
|
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Object}
|
|
272
272
|
*/
|
|
273
273
|
}, {
|
|
@@ -464,7 +464,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
464
464
|
/**
|
|
465
465
|
* Get current party
|
|
466
466
|
* Get the party the authenticated user is currently in, including members.
|
|
467
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
467
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AcceptPartyInvite200Response} and HTTP response
|
|
468
468
|
*/
|
|
469
469
|
}, {
|
|
470
470
|
key: "showPartyWithHttpInfo",
|
|
@@ -477,14 +477,14 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
477
477
|
var authNames = ['authorization'];
|
|
478
478
|
var contentTypes = [];
|
|
479
479
|
var accepts = ['application/json'];
|
|
480
|
-
var returnType =
|
|
480
|
+
var returnType = _AcceptPartyInvite200Response["default"];
|
|
481
481
|
return this.apiClient.callApi('/api/v1/parties/me', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
/**
|
|
485
485
|
* Get current party
|
|
486
486
|
* Get the party the authenticated user is currently in, including members.
|
|
487
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
487
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AcceptPartyInvite200Response}
|
|
488
488
|
*/
|
|
489
489
|
}, {
|
|
490
490
|
key: "showParty",
|
|
@@ -499,7 +499,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
499
499
|
* Update party settings such as max_size and metadata. Only the leader can update.
|
|
500
500
|
* @param {Object} opts Optional parameters
|
|
501
501
|
* @param {module:model/UpdatePartyRequest} [updatePartyRequest] Party update parameters
|
|
502
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/
|
|
502
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AcceptPartyInvite200Response} and HTTP response
|
|
503
503
|
*/
|
|
504
504
|
}, {
|
|
505
505
|
key: "updatePartyWithHttpInfo",
|
|
@@ -513,7 +513,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
513
513
|
var authNames = ['authorization'];
|
|
514
514
|
var contentTypes = ['application/json'];
|
|
515
515
|
var accepts = ['application/json'];
|
|
516
|
-
var returnType =
|
|
516
|
+
var returnType = _AcceptPartyInvite200Response["default"];
|
|
517
517
|
return this.apiClient.callApi('/api/v1/parties', 'PATCH', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
|
|
518
518
|
}
|
|
519
519
|
|
|
@@ -522,7 +522,7 @@ var PartiesApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
522
522
|
* Update party settings such as max_size and metadata. Only the leader can update.
|
|
523
523
|
* @param {Object} opts Optional parameters
|
|
524
524
|
* @param {module:model/UpdatePartyRequest} opts.updatePartyRequest Party update parameters
|
|
525
|
-
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/
|
|
525
|
+
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AcceptPartyInvite200Response}
|
|
526
526
|
*/
|
|
527
527
|
}, {
|
|
528
528
|
key: "updateParty",
|
package/dist/api/PaymentsApi.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
|
|
8
|
-
var
|
|
8
|
+
var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
|
|
9
9
|
var _PaymentsSteamCheckoutRequest = _interopRequireDefault(require("../model/PaymentsSteamCheckoutRequest"));
|
|
10
10
|
var _PaymentsSteamFinalizeRequest = _interopRequireDefault(require("../model/PaymentsSteamFinalizeRequest"));
|
|
11
11
|
var _PaymentsStripeCheckoutRequest = _interopRequireDefault(require("../model/PaymentsStripeCheckoutRequest"));
|
|
@@ -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.
|
|
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).
|
package/dist/api/UsersApi.js
CHANGED
|
@@ -5,12 +5,12 @@ 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 _GetCurrentUser200Response = _interopRequireDefault(require("../model/GetCurrentUser200Response"));
|
|
9
|
+
var _PaymentsEntitlements401Response = _interopRequireDefault(require("../model/PaymentsEntitlements401Response"));
|
|
10
10
|
var _SearchUsers200Response = _interopRequireDefault(require("../model/SearchUsers200Response"));
|
|
11
11
|
var _SearchUsers200ResponseDataInner = _interopRequireDefault(require("../model/SearchUsers200ResponseDataInner"));
|
|
12
|
+
var _UpdateCurrentUserDisplayName400Response = _interopRequireDefault(require("../model/UpdateCurrentUserDisplayName400Response"));
|
|
12
13
|
var _UpdateCurrentUserDisplayNameRequest = _interopRequireDefault(require("../model/UpdateCurrentUserDisplayNameRequest"));
|
|
13
|
-
var _UpdateCurrentUserPassword400Response = _interopRequireDefault(require("../model/UpdateCurrentUserPassword400Response"));
|
|
14
14
|
var _UpdateCurrentUserPasswordRequest = _interopRequireDefault(require("../model/UpdateCurrentUserPasswordRequest"));
|
|
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); }
|
|
@@ -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.
|
|
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).
|