client_port.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 ServerPort;
  11. class ClientSession;
  12. class ClientPort final : public Object {
  13. public:
  14. friend class ServerPort;
  15. std::string GetTypeName() const override {
  16. return "ClientPort";
  17. }
  18. std::string GetName() const override {
  19. return name;
  20. }
  21. static const HandleType HANDLE_TYPE = HandleType::ClientPort;
  22. HandleType GetHandleType() const override {
  23. return HANDLE_TYPE;
  24. }
  25. /**
  26. * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's
  27. * list of pending sessions, and signals the ServerPort, causing any threads
  28. * waiting on it to awake.
  29. * @returns ClientSession The client endpoint of the created Session pair, or error code.
  30. */
  31. ResultVal<SharedPtr<ClientSession>> Connect();
  32. /**
  33. * Signifies that a previously active connection has been closed,
  34. * decreasing the total number of active connections to this port.
  35. */
  36. void ConnectionClosed();
  37. private:
  38. ClientPort();
  39. ~ClientPort() override;
  40. SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
  41. u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have
  42. u32 active_sessions = 0; ///< Number of currently open sessions to this port
  43. std::string name; ///< Name of client port (optional)
  44. };
  45. } // namespace Kernel