Features:
- New DeviceSettings admin page at /devicesettings
- Manage device server configurations (URL, mode, deviceId)
- 3 new API endpoints for APK sync functionality
- UserSettings database model with SQLite storage
Implementation:
- ServerSettingsController.cs with getUserSettings, updateUserSettings, getAllUserSettings
- DeviceSettings.cshtml Razor page with add/edit/delete UI
- DeviceSettings.cshtml.cs page model with CRUD operations
- UserSettings model added to ApiModels.cs
- UserSettings DbSet added to RR3DbContext
- EF Core migration: 20260219180936_AddUserSettings
- Link added to Admin dashboard
API Endpoints:
- GET /api/settings/getUserSettings?deviceId={id} - APK sync endpoint
- POST /api/settings/updateUserSettings - Web panel update
- GET /api/settings/getAllUserSettings - Admin list view
Database Schema:
- UserSettings table (Id, DeviceId, ServerUrl, Mode, LastUpdated)
- SQLite storage with EF Core migrations
Integration:
- Works with APK SettingsActivity sync button
- Real-time configuration updates
- Emoji logging for all operations
- Device-specific server URL management
Usage:
1. Admin configures device settings at /devicesettings
2. User opens RR3 APK and taps Sync from Web Panel
3. APK downloads settings via API
4. Settings saved to SharedPreferences
5. Game restart applies configuration
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
133 lines
4.0 KiB
C#
133 lines
4.0 KiB
C#
namespace RR3CommunityServer.Models;
|
|
|
|
// User Settings for Server Configuration
|
|
public class UserSettings
|
|
{
|
|
public int Id { get; set; }
|
|
public string DeviceId { get; set; } = string.Empty;
|
|
public string ServerUrl { get; set; } = string.Empty;
|
|
public string Mode { get; set; } = "offline"; // "online" or "offline"
|
|
public DateTime LastUpdated { get; set; } = DateTime.UtcNow;
|
|
}
|
|
|
|
// Progression request/response models
|
|
public class ProgressionUpdate
|
|
{
|
|
public int? GoldEarned { get; set; }
|
|
public int? CashEarned { get; set; }
|
|
public int? ExperienceEarned { get; set; }
|
|
public int? ReputationEarned { get; set; }
|
|
}
|
|
|
|
public class CarPurchaseRequest
|
|
{
|
|
public string SynergyId { get; set; } = string.Empty;
|
|
public string CarId { get; set; } = string.Empty;
|
|
public bool UseGold { get; set; } = false;
|
|
}
|
|
|
|
public class CarUpgradeRequest
|
|
{
|
|
public string SynergyId { get; set; } = string.Empty;
|
|
public string CarId { get; set; } = string.Empty;
|
|
public string UpgradeType { get; set; } = string.Empty; // engine, tires, suspension, etc.
|
|
}
|
|
|
|
public class CareerEventCompletion
|
|
{
|
|
public string SynergyId { get; set; } = string.Empty;
|
|
public string SeriesName { get; set; } = string.Empty;
|
|
public string EventName { get; set; } = string.Empty;
|
|
public int StarsEarned { get; set; } // 1-3 stars
|
|
public double RaceTime { get; set; }
|
|
}
|
|
|
|
// Standard Synergy API response wrapper
|
|
public class SynergyResponse<T>
|
|
{
|
|
public int resultCode { get; set; } = 0; // 0 = success, negative = error
|
|
public string? message { get; set; }
|
|
public T? data { get; set; }
|
|
}
|
|
|
|
// User models
|
|
public class DeviceIdResponse
|
|
{
|
|
public string deviceId { get; set; } = string.Empty;
|
|
public string synergyId { get; set; } = string.Empty;
|
|
public long timestamp { get; set; }
|
|
}
|
|
|
|
public class AnonUidResponse
|
|
{
|
|
public string anonUid { get; set; } = string.Empty;
|
|
public long expiresAt { get; set; }
|
|
}
|
|
|
|
// Product/Catalog models
|
|
public class CatalogItem
|
|
{
|
|
public string itemId { get; set; } = string.Empty;
|
|
public string sku { get; set; } = string.Empty;
|
|
public string name { get; set; } = string.Empty;
|
|
public string description { get; set; } = string.Empty;
|
|
public string category { get; set; } = string.Empty;
|
|
public decimal price { get; set; }
|
|
public string currency { get; set; } = "USD";
|
|
public Dictionary<string, object> metadata { get; set; } = new();
|
|
}
|
|
|
|
public class CatalogCategory
|
|
{
|
|
public string categoryId { get; set; } = string.Empty;
|
|
public string name { get; set; } = string.Empty;
|
|
public List<string> itemIds { get; set; } = new();
|
|
}
|
|
|
|
// DRM models
|
|
public class DrmNonceResponse
|
|
{
|
|
public string nonce { get; set; } = string.Empty;
|
|
public long expiresAt { get; set; }
|
|
}
|
|
|
|
public class PurchasedItem
|
|
{
|
|
public string itemId { get; set; } = string.Empty;
|
|
public string sku { get; set; } = string.Empty;
|
|
public string orderId { get; set; } = string.Empty;
|
|
public long purchaseTime { get; set; }
|
|
public string token { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class PurchaseVerificationRequest
|
|
{
|
|
public string receipt { get; set; } = string.Empty;
|
|
public string signature { get; set; } = string.Empty;
|
|
public string sku { get; set; } = string.Empty;
|
|
public string orderId { get; set; } = string.Empty;
|
|
}
|
|
|
|
// Tracking models
|
|
public class TrackingEvent
|
|
{
|
|
public string eventType { get; set; } = string.Empty;
|
|
public long timestamp { get; set; }
|
|
public Dictionary<string, object> properties { get; set; } = new();
|
|
}
|
|
|
|
// Director/Service Discovery
|
|
public class DirectorResponse
|
|
{
|
|
public Dictionary<string, string> serverUrls { get; set; } = new()
|
|
{
|
|
{ "synergy.product", "https://localhost:5001" },
|
|
{ "synergy.drm", "https://localhost:5001" },
|
|
{ "synergy.user", "https://localhost:5001" },
|
|
{ "synergy.tracking", "https://localhost:5001" },
|
|
{ "synergy.s2s", "https://localhost:5001" }
|
|
};
|
|
public string environment { get; set; } = "COMMUNITY";
|
|
public string version { get; set; } = "1.0.0";
|
|
}
|