client_port.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <string>
  6. #include "common/common_types.h"
  7. #include "core/hle/kernel/object.h"
  8. #include "core/hle/result.h"
  9. namespace Kernel {
  10. class ClientSession;
  11. class KernelCore;
  12. class ServerPort;
  13. class ClientPort final : public Object {
  14. public:
  15. friend class ServerPort;
  16. std::string GetTypeName() const override {
  17. return "ClientPort";
  18. }
  19. std::string GetName() const override {
  20. return name;
  21. }
  22. static const HandleType HANDLE_TYPE = HandleType::ClientPort;
  23. HandleType GetHandleType() const override {
  24. return HANDLE_TYPE;
  25. }
  26. SharedPtr<ServerPort> GetServerPort() const;
  27. /**
  28. * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's
  29. * list of pending sessions, and signals the ServerPort, causing any threads
  30. * waiting on it to awake.
  31. * @returns ClientSession The client endpoint of the created Session pair, or error code.
  32. */
  33. ResultVal<SharedPtr<ClientSession>> Connect();
  34. /**
  35. * Signifies that a previously active connection has been closed,
  36. * decreasing the total number of active connections to this port.
  37. */
  38. void ConnectionClosed();
  39. private:
  40. explicit ClientPort(KernelCore& kernel);
  41. ~ClientPort() override;
  42. SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
  43. u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have
  44. u32 active_sessions = 0; ///< Number of currently open sessions to this port
  45. std::string name; ///< Name of client port (optional)
  46. };
  47. } // namespace Kernel