mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-04 15:18:17 +00:00
119 lines
2.8 KiB
C#
119 lines
2.8 KiB
C#
// <auto-generated/> by Diplomat
|
|
|
|
#pragma warning disable 0105
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
using Devolutions.IronRdp.Diplomat;
|
|
#pragma warning restore 0105
|
|
|
|
namespace Devolutions.IronRdp;
|
|
|
|
#nullable enable
|
|
|
|
public partial class ClientState: IDisposable
|
|
{
|
|
private unsafe Raw.ClientState* _inner;
|
|
|
|
public TsRequest TsRequest
|
|
{
|
|
get
|
|
{
|
|
return GetTsRequest();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a managed <c>ClientState</c> from a raw handle.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free).
|
|
/// <br/>
|
|
/// This constructor assumes the raw struct is allocated on Rust side.
|
|
/// If implemented, the custom Drop implementation on Rust side WILL run on destruction.
|
|
/// </remarks>
|
|
public unsafe ClientState(Raw.ClientState* handle)
|
|
{
|
|
_inner = handle;
|
|
}
|
|
|
|
public bool IsReplyNeeded()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("ClientState");
|
|
}
|
|
bool retVal = Raw.ClientState.IsReplyNeeded(_inner);
|
|
return retVal;
|
|
}
|
|
}
|
|
|
|
public bool IsFinalMessage()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("ClientState");
|
|
}
|
|
bool retVal = Raw.ClientState.IsFinalMessage(_inner);
|
|
return retVal;
|
|
}
|
|
}
|
|
|
|
/// <exception cref="IronRdpException"></exception>
|
|
/// <returns>
|
|
/// A <c>TsRequest</c> allocated on Rust side.
|
|
/// </returns>
|
|
public TsRequest GetTsRequest()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("ClientState");
|
|
}
|
|
Raw.CredsspNetworkFfiResultBoxTsRequestBoxIronRdpError result = Raw.ClientState.GetTsRequest(_inner);
|
|
if (!result.isOk)
|
|
{
|
|
throw new IronRdpException(new IronRdpError(result.Err));
|
|
}
|
|
Raw.TsRequest* retVal = result.Ok;
|
|
return new TsRequest(retVal);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the underlying raw handle.
|
|
/// </summary>
|
|
public unsafe Raw.ClientState* AsFFI()
|
|
{
|
|
return _inner;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Destroys the underlying object immediately.
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Raw.ClientState.Destroy(_inner);
|
|
_inner = null;
|
|
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|
|
|
|
~ClientState()
|
|
{
|
|
Dispose();
|
|
}
|
|
}
|