diff options
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Kernel/Ipc/KSession.cs')
-rw-r--r-- | src/Ryujinx.HLE/HOS/Kernel/Ipc/KSession.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KSession.cs b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KSession.cs new file mode 100644 index 00000000..13cf4b51 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KSession.cs @@ -0,0 +1,54 @@ +using Ryujinx.HLE.HOS.Kernel.Common; +using Ryujinx.HLE.HOS.Kernel.Process; + +namespace Ryujinx.HLE.HOS.Kernel.Ipc +{ + class KSession : KAutoObject + { + public KServerSession ServerSession { get; } + public KClientSession ClientSession { get; } + + private bool _hasBeenInitialized; + + public KSession(KernelContext context, KClientPort parentPort = null) : base(context) + { + IncrementReferenceCount(); + + ServerSession = new KServerSession(context, this); + ClientSession = new KClientSession(context, this, parentPort); + + _hasBeenInitialized = true; + } + + public void DisconnectClient() + { + if (ClientSession.State == ChannelState.Open) + { + ClientSession.State = ChannelState.ClientDisconnected; + + ServerSession.CancelAllRequestsClientDisconnected(); + } + } + + public void DisconnectServer() + { + if (ClientSession.State == ChannelState.Open) + { + ClientSession.State = ChannelState.ServerDisconnected; + } + } + + protected override void Destroy() + { + if (_hasBeenInitialized) + { + ClientSession.DisconnectFromPort(); + + KProcess creatorProcess = ClientSession.CreatorProcess; + + creatorProcess.ResourceLimit?.Release(LimitableResource.Session, 1); + creatorProcess.DecrementReferenceCount(); + } + } + } +}
\ No newline at end of file |