Initial commit: Ananta CBT 4229938 private server with all fixes
This commit is contained in:
commit
c84135c357
286 files changed
+2214315
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using Ananta.SDK.Serialization;
|
||||
|
||||
using Ananta.SDK.Logging;
|
||||
|
||||
namespace Ananta.SDK.Rpc;
|
||||
|
||||
/// <summary>A parsed UX RPC message exposed to attribute handlers.</summary>
|
||||
public sealed class UxRpcMessage
|
||||
{
|
||||
public RpcContext Context { get; }
|
||||
public RpcPacketKind Kind => Context.Packet.Kind;
|
||||
public uint MethodId => Context.MethodId;
|
||||
public int InvokeId => Context.InvokeId;
|
||||
public byte[] Body => Context.Body;
|
||||
public bool IsInvoke => Kind == RpcPacketKind.Invoke;
|
||||
public bool IsNotify => Kind == RpcPacketKind.Notify;
|
||||
|
||||
internal UxRpcMessage(RpcContext context) => Context = context;
|
||||
|
||||
public T GetArgs<T>()
|
||||
{
|
||||
var value = UxSerializer.Deserialize<T>(Body);
|
||||
RuntimeLogs.Decoded(Context.Session.Log.Scope, "C2S", MethodId, typeof(T), value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public bool TryGetArgs<T>(out T value)
|
||||
{
|
||||
try
|
||||
{
|
||||
value = GetArgs<T>();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = default!;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user