![]() |
VOOZH | about |
dotnet add package GameFrameX.Client --version 1.0.0
NuGet\Install-Package GameFrameX.Client -Version 1.0.0
<PackageReference Include="GameFrameX.Client" Version="1.0.0" />
<PackageVersion Include="GameFrameX.Client" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="GameFrameX.Client" />Project file
paket add GameFrameX.Client --version 1.0.0
#r "nuget: GameFrameX.Client, 1.0.0"
#:package GameFrameX.Client@1.0.0
#addin nuget:?package=GameFrameX.Client&version=1.0.0Install as a Cake Addin
#tool nuget:?package=GameFrameX.Client&version=1.0.0Install as a Cake Tool
้ซๆง่ฝใ่ทจๅนณๅฐ็ๆธธๆๆๅกๅจๆกๆถ
GameFrameX ๆฏไธไธชๅบไบ C# .NET 8.0 ๅผๅ็้ซๆง่ฝใ่ทจๅนณๅฐๆธธๆๆๅกๅจๆกๆถ๏ผ้็จ Actor ๆจกๅ่ฎพ่ฎก๏ผๆฏๆ็ญๆดๆฐๆบๅถใไธไธบๅคไบบๅจ็บฟๆธธๆๅผๅ่่ฎพ่ฎก๏ผๅฎ็พๆฏๆ Unity3D ๅฎขๆท็ซฏ้ๆใ
่ฎพ่ฎก็ๅฟต๏ผๅคง้่ณ็ฎ๏ผไปฅ็ฎๅ็น
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๅฎขๆท็ซฏๅฑ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ็ฝ็ปๅฑ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ TCP โ โ WebSocket โ โ HTTP โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๆถๆฏๅค็ๅฑ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๆถๆฏๅค็ๅจ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Actor ๅฑ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ ็ฉๅฎถ โ โ ๆๅกๅจ โ โ ่ดฆๆท โ โ
โ โ Actor โ โ Actor โ โ Actor โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ็ปไปถๅฑ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ ็ปไปถ โ โ ็ปไปถ โ โ ็ปไปถ โ โ
โ โ + ็ถๆ โ โ + ็ถๆ โ โ + ็ถๆ โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๆฐๆฎๅบๅฑ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ MongoDB โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ๅ ้ไปๅบ
git clone https://github.com/GameFrameX/GameFrameX.git
cd GameFrameX
่ฟๅไพ่ต
dotnet restore
้ ็ฝฎๆฐๆฎๅบ
ๆๅปบ่ฟ่ก
dotnet build
dotnet run --project GameFrameX.Launcher --ServerType=Game --ServerId=1000
้ช่ฏ้จ็ฝฒ
http://localhost:29090/healthGameFrameX/
โโโ GameFrameX.Apps/ # ๅบ็จๅฑ๏ผ็ถๆๆฐๆฎ๏ผ
โ โโโ Account/ # ่ดฆๆทๆจกๅ็ถๆ
โ โโโ Player/ # ็ฉๅฎถๆจกๅ็ถๆ
โ โโโ Server/ # ๆๅกๅจๆจกๅ็ถๆ
โโโ GameFrameX.Hotfix/ # ็ญๆดๆฐๅฑ๏ผไธๅก้ป่พ๏ผ
โ โโโ Logic/ # ไธๅก้ป่พๅฎ็ฐ
โ โโโ StartUp/ # ็ญๆดๆฐๅฏๅจ้ป่พ
โโโ GameFrameX.Core/ # ๆ ธๅฟๆกๆถ
โ โโโ Actors/ # Actor ็ณป็ปๅฎ็ฐ
โ โโโ Components/ # ็ปไปถ็ณป็ป
โ โโโ Events/ # ไบไปถ็ณป็ป
โโโ GameFrameX.NetWork/ # ็ฝ็ป้ไฟก
โโโ GameFrameX.DataBase.Mongo/ # MongoDB ้ๆ
โโโ GameFrameX.Config/ # ้
็ฝฎ็ฎก็
โโโ GameFrameX.Monitor/ # ็ๆงๅๆๆ
โโโ GameFrameX.Launcher/ # ๅบ็จๅ
ฅๅฃ็น
โโโ GameFrameX.StartUp/ # ๅฏๅจ็ผๆ
ๅฟซ้ๅๅปบไธไธช HTTP ๆฅๅฃๆฅไฝ้ชๅผๅๆต็จใ
using GameFrameX.NetWork.HTTP;
[HttpMessageMapping(typeof(TestHttpHandler))]
[HttpMessageResponse(typeof(HttpTestResponse))]
[Description("Hello World ็คบไพๆฅๅฃ")]
public sealed class TestHttpHandler : BaseHttpHandler
{
public override Task<string> Action(string ip, string url, Dictionary<string, object> parameters)
{
var response = new HttpTestResponse
{
Message = "Hello World From GameFrameX",
Time = DateTime.Now
};
// ่ฟๅๆ ๅ JSON ๆ ผๅผ
return Task.FromResult(HttpJsonResult.SuccessString(response));
}
}
public sealed class HttpTestResponse : HttpMessageResponseBase
{
public string Message { get; set; }
public DateTime Time { get; set; }
}
1. ๅฎไน็ถๆ๏ผApps ๅฑ - ไธๅฏ็ญๆด๏ผ
public class BagState : CacheState
{
public List<ItemData> Items { get; set; } = new();
public int MaxSlots { get; set; } = 50;
}
2. ๅๅปบ็ปไปถ๏ผApps ๅฑ๏ผ
public class BagComponent : StateComponent<BagState>
{
// ็ปไปถๅๅงๅ้ป่พ
protected override async Task OnInit()
{
await base.OnInit();
// ๅๅงๅ็ปไปถ็ถๆ
}
}
3. ๅฎ็ฐไธๅก้ป่พ๏ผHotfix ๅฑ - ๅฏ็ญๆด๏ผ
public class BagComponentAgent : StateComponentAgent<BagComponent, BagState>
{
public async Task<bool> AddItem(int itemId, int count)
{
if (State.Items.Count >= State.MaxSlots)
return false;
var item = new ItemData { Id = itemId, Count = count };
State.Items.Add(item);
await Save();
return true;
}
}
HTTP ๅค็ๅจ็คบไพ๏ผ
[HttpMessageMapping(typeof(GetPlayerInventoryHttpHandler))]
[Description("่ทๅ็ฉๅฎถ่ๅ
็ฉๅ")]
public sealed class GetPlayerInventoryHttpHandler : BaseHttpHandler
{
public override async Task<MessageObject> Action(string ip, string url, Dictionary<string, object> parameters, MessageObject messageObject)
{
var request = (GetPlayerInventoryRequest)messageObject;
var response = new GetPlayerInventoryResponse();
// ไปๅๆฐไธญ่ทๅ็ฉๅฎถID
if (!parameters.TryGetValue("playerId", out var playerIdObj))
{
response.ErrorCode = (int)ResultCode.InvalidParameter;
return response;
}
var playerId = Convert.ToInt64(playerIdObj);
var bagAgent = await ActorManager.GetComponentAgent<BagComponentAgent>(playerId);
if (bagAgent == null)
{
response.ErrorCode = (int)ResultCode.PlayerNotFound;
return response;
}
var items = await bagAgent.GetItems();
response.Items = items;
return response;
}
}
RPC ๅค็ๅจ็คบไพ๏ผ
[MessageMapping(typeof(ReqAddItem))]
internal sealed class AddItemHandler : PlayerRpcComponentHandler<BagComponentAgent, ReqAddItem, RespAddItem>
{
protected override async Task ActionAsync(ReqAddItem request, RespAddItem response)
{
try
{
// ComponentAgent ็ฑๅบ็ฑป่ชๅจๆณจๅ
ฅ,ๆ ้ๆๅจ่ทๅ
await ComponentAgent.AddItem(request, response);
}
catch (Exception e)
{
LogHelper.Fatal(e);
response.ErrorCode = (int)OperationStatusCode.InternalServerError;
}
}
}
[Event(EventId.PlayerLogin)]
internal sealed class PlayerLoginEventHandler : EventListener<PlayerComponentAgent>
{
protected override Task HandleEvent(PlayerComponentAgent agent, GameEventArgs gameEventArgs)
{
if (agent == null)
{
LogHelper.Error("ไปฃ็ๅฏน่ฑกไธบ็ฉบ");
return Task.CompletedTask;
}
// ๅค็็ปๅฝไบไปถ้ป่พ
return agent.OnLogin();
}
}
็ญๆดๆฐ็ณป็ปๅฐ็ถๆ๏ผๆไน ๅๆฐๆฎ๏ผไธ้ป่พ๏ผไธๅก่งๅ๏ผๅ็ฆป๏ผ
GameFrameX.Hotfix.dll/hotfix ็ฎๅฝ# ้่ฟ HTTP ่งฆๅ็ญๆดๆฐ
curl -X POST http://localhost:29090/api/reload
# ๆฃๆฅ้่ฝฝ็ถๆ
curl http://localhost:29090/api/reload/status
GameFrameX ไฝฟ็จๆๅนณๅ็้
็ฝฎ็ปๆ๏ผๆฏๆๅฝไปค่กๅๆฐ (--Key=Value)ใ็ฏๅขๅ้ (Key=Value) ๅ appsettings.json ้
็ฝฎๆไปถใ
| ้ ็ฝฎ้กน | ่ฏดๆ | ้ป่ฎคๅผ | ็คบไพ |
|---|---|---|---|
ServerType |
ๆๅกๅจ็ฑปๅ (ๅฆ Game, Gate) | ๆ | Game |
ServerId |
ๆๅกๅจๅฏไธๆ ่ฏ ID | ๆ | 1000 |
ServerName |
ๆๅกๅจๅ็งฐ | ๅ ServerType | Game-1 |
MinModuleId |
ไธๅกๆจกๅ่ตทๅง ID | 0 | 100 |
MaxModuleId |
ไธๅกๆจกๅ็ปๆ ID | 0 | 1000 |
| ้ ็ฝฎ้กน | ่ฏดๆ | ้ป่ฎคๅผ | ็คบไพ |
|---|---|---|---|
InnerHost |
ๅ ้จ้ไฟก IP (้็พค้ด) | ๆ | 0.0.0.0 |
InnerPort |
ๅ ้จ้ไฟก็ซฏๅฃ | ๆ | 29100 |
OuterHost |
ๅค้จ้ไฟก IP (้ขๅๅฎขๆท็ซฏ) | ๆ | 0.0.0.0 |
OuterPort |
ๅค้จ้ไฟก็ซฏๅฃ | ๆ | 29200 |
HttpPort |
HTTP ๆๅก็ซฏๅฃ | 0 | 8080 |
WsPort |
WebSocket ๆๅก็ซฏๅฃ | 0 | 29300 |
| ้ ็ฝฎ้กน | ่ฏดๆ | ้ป่ฎคๅผ | ็คบไพ |
|---|---|---|---|
DataBaseUrl |
MongoDB ่ฟๆฅๅญ็ฌฆไธฒ | ๆ | mongodb://localhost:27017 |
DataBaseName |
ๆฐๆฎๅบๅ็งฐ | ๆ | gameframex |
| ้ ็ฝฎ้กน | ่ฏดๆ | ้ป่ฎคๅผ | ็คบไพ |
|---|---|---|---|
IsOpenTelemetry |
ๆฏๅฆๅฏ็จ OpenTelemetry | false |
true |
MetricsPort |
Prometheus ๆๆ ็ซฏๅฃ | 0 (ๅค็จ HTTP) | 9090 |
IsDebug |
ๅผๅฏ่ฐ่ฏๆฅๅฟ | false |
true |
dotnet GameFrameX.Launcher.dll \
--ServerType=Game \
--ServerId=1000 \
--OuterPort=10000 \
--DataBaseUrl=mongodb://127.0.0.1:27017 \
--DataBaseName=game_db
# ๆๅปบ้ถๆฎต
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore && dotnet build -c Release
# ่ฟ่ก้ถๆฎต
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /src/bin/Release/net8.0/ .
EXPOSE 29100 29110 29090
ENTRYPOINT ["dotnet", "GameFrameX.Launcher.dll"]
# docker-compose.yml
version: '3.8'
services:
gameframex:
build: .
ports:
- "29100:29100" # TCP
- "29110:29110" # WebSocket
- "29090:29090" # ๆๆ
environment:
- ServerType=Game
- ServerId=1000
- DataBaseUrl=mongodb://mongodb:27017
depends_on:
- mongodb
mongodb:
image: mongo:6.0
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
volumes:
mongodb_data:
http://localhost:29090/healthhttp://localhost:29090/metricsๆไปฌๆฌข่ฟไปปไฝๅฝขๅผ็่ดก็ฎ๏ผๅฆๆไฝ ๆณไธบ GameFrameX ๅๅบ่ดก็ฎ๏ผ่ฏท้ตๅพชไปฅไธๆญฅ้ชค๏ผ
git checkout -b feature/amazing-feature๏ผgit commit -m 'ๆทปๅ ๆไธชๅ่ฝ'๏ผgit push origin feature/amazing-feature๏ผๆฌ้กน็ฎ้็จ Apache License 2.0 ่ฎธๅฏ่ฏ - ่ฏฆ่ง ๆไปถใ
<div align="center">
ๅฆๆ่ฟไธช้กน็ฎๅฏนไฝ ๆๅธฎๅฉ๏ผ่ฏท็ปๆไปฌไธไธช โญ
Made with โค๏ธ by GameFrameX Team
</div>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 124 | 3/24/2026 |