FriendsServerManager.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Ryujinx.Horizon.Common;
  2. using Ryujinx.Horizon.Sdk.Account;
  3. using Ryujinx.Horizon.Sdk.Friends.Detail.Ipc;
  4. using Ryujinx.Horizon.Sdk.Sf.Hipc;
  5. using Ryujinx.Horizon.Sdk.Sm;
  6. using System;
  7. namespace Ryujinx.Horizon.Friends
  8. {
  9. class FriendsServerManager : ServerManager
  10. {
  11. private readonly IEmulatorAccountManager _accountManager;
  12. private readonly NotificationEventHandler _notificationEventHandler;
  13. public FriendsServerManager(HeapAllocator allocator, SmApi sm, int maxPorts, ManagerOptions options, int maxSessions) : base(allocator, sm, maxPorts, options, maxSessions)
  14. {
  15. _accountManager = HorizonStatic.Options.AccountManager;
  16. _notificationEventHandler = new();
  17. }
  18. protected override Result OnNeedsToAccept(int portIndex, Server server)
  19. {
  20. return (FriendsPortIndex)portIndex switch
  21. {
  22. #pragma warning disable IDE0055 // Disable formatting
  23. FriendsPortIndex.Admin => AcceptImpl(server, new ServiceCreator(_accountManager, _notificationEventHandler, FriendsServicePermissionLevel.Admin)),
  24. FriendsPortIndex.User => AcceptImpl(server, new ServiceCreator(_accountManager, _notificationEventHandler, FriendsServicePermissionLevel.User)),
  25. FriendsPortIndex.Viewer => AcceptImpl(server, new ServiceCreator(_accountManager, _notificationEventHandler, FriendsServicePermissionLevel.Viewer)),
  26. FriendsPortIndex.Manager => AcceptImpl(server, new ServiceCreator(_accountManager, _notificationEventHandler, FriendsServicePermissionLevel.Manager)),
  27. FriendsPortIndex.System => AcceptImpl(server, new ServiceCreator(_accountManager, _notificationEventHandler, FriendsServicePermissionLevel.System)),
  28. _ => throw new ArgumentOutOfRangeException(nameof(portIndex)),
  29. #pragma warning restore IDE0055
  30. };
  31. }
  32. }
  33. }