client_session.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/assert.h"
  5. #include "core/hle/kernel/client_session.h"
  6. #include "core/hle/kernel/errors.h"
  7. #include "core/hle/kernel/hle_ipc.h"
  8. #include "core/hle/kernel/server_session.h"
  9. #include "core/hle/kernel/session.h"
  10. namespace Kernel {
  11. ClientSession::ClientSession() = default;
  12. ClientSession::~ClientSession() {
  13. // This destructor will be called automatically when the last ClientSession handle is closed by
  14. // the emulated application.
  15. // Local references to ServerSession and SessionRequestHandler are necessary to guarantee they
  16. // will be kept alive until after ClientDisconnected() returns.
  17. SharedPtr<ServerSession> server = parent->server;
  18. if (server) {
  19. std::shared_ptr<SessionRequestHandler> hle_handler = server->hle_handler;
  20. if (hle_handler)
  21. hle_handler->ClientDisconnected(server);
  22. // TODO(Subv): Force a wake up of all the ServerSession's waiting threads and set
  23. // their WaitSynchronization result to 0xC920181A.
  24. }
  25. parent->client = nullptr;
  26. }
  27. ResultCode ClientSession::SendSyncRequest() {
  28. // Keep ServerSession alive until we're done working with it.
  29. SharedPtr<ServerSession> server = parent->server;
  30. if (server == nullptr)
  31. return ERR_SESSION_CLOSED_BY_REMOTE;
  32. // Signal the server session that new data is available
  33. return server->HandleSyncRequest();
  34. }
  35. } // namespace