Initial commit: Ananta CBT 4229938 private server with all fixes

This commit is contained in:
CAtlas0784 committed 2026-09-15 18:13:46 +07:00
commit c84135c357
286 files changed
+2214315

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
using Ananta.SDK.Logging;
using Ananta.SDK.Network;
using Ananta.SDK.Serialization;
namespace Ananta.SDK.Rpc;
public sealed class RpcContext
{
public TcpSession Session { get; }
public RpcPacket Packet { get; }
public CancellationToken CancellationToken { get; }
public uint MethodId => Packet.MethodId;
public int InvokeId => Packet.InvokeId;
public byte[] Body => Packet.Body;
public RpcContext(TcpSession session, RpcPacket packet, CancellationToken cancellationToken)
{
Session = session;
Packet = packet;
CancellationToken = cancellationToken;
}
public Task ReturnAsync(byte[] body, int err = 0)
=> Session.ReturnAsync(MethodId, InvokeId, err, body, CancellationToken);
public Task ReturnEmptyOkAsync()
=> ReturnAsync(Array.Empty<byte>());
public Task ReturnAsync<T>(T body, int err = 0)
{
var bytes = UxSerializer.Serialize(body);
var send = ReturnAsync(bytes, err);
RuntimeLogs.Decoded(Session.Log.Scope, "S2C", MethodId, typeof(T), body);
return send;
}
public Task NotifyAsync(uint methodId, byte[] body)
=> Session.NotifyAsync(methodId, body, CancellationToken);
public Task NotifyAsync<T>(uint methodId, T body)
{
var bytes = UxSerializer.Serialize(body);
var send = NotifyAsync(methodId, bytes);
RuntimeLogs.Decoded(Session.Log.Scope, "S2C", methodId, typeof(T), body);
return send;
}
}