client_port.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. /**
  27. * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's
  28. * list of pending sessions, and signals the ServerPort, causing any threads
  29. * waiting on it to awake.
  30. * @returns ClientSession The client endpoint of the created Session pair, or error code.
  31. */
  32. ResultVal<SharedPtr<ClientSession>> Connect();
  33. /**
  34. * Signifies that a previously active connection has been closed,
  35. * decreasing the total number of active connections to this port.
  36. */
  37. void ConnectionClosed();
  38. private:
  39. explicit ClientPort(KernelCore& kernel);
  40. ~ClientPort() override;
  41. SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
  42. u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have
  43. u32 active_sessions = 0; ///< Number of currently open sessions to this port
  44. std::string name; ///< Name of client port (optional)
  45. };
  46. } // namespace Kernel