summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/client_session.cpp
blob: 13c55abe44459e8e8769646b4d41b4d2260915bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include "core/hle/kernel/client_session.h"
#include "core/hle/kernel/hle_ipc.h"
#include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/server_session.h"
#include "core/hle/kernel/session.h"
#include "core/hle/kernel/svc_results.h"
#include "core/hle/result.h"

namespace Kernel {

ClientSession::ClientSession(KernelCore& kernel) : KSynchronizationObject{kernel} {}

ClientSession::~ClientSession() {
    // This destructor will be called automatically when the last ClientSession handle is closed by
    // the emulated application.
    if (parent->Server()) {
        parent->Server()->ClientDisconnected();
    }
}

bool ClientSession::IsSignaled() const {
    UNIMPLEMENTED();
    return true;
}

ResultVal<std::shared_ptr<ClientSession>> ClientSession::Create(KernelCore& kernel,
                                                                std::shared_ptr<Session> parent,
                                                                std::string name) {
    std::shared_ptr<ClientSession> client_session{std::make_shared<ClientSession>(kernel)};

    client_session->name = std::move(name);
    client_session->parent = std::move(parent);

    return MakeResult(std::move(client_session));
}

ResultCode ClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory,
                                          Core::Timing::CoreTiming& core_timing) {
    // Keep ServerSession alive until we're done working with it.
    if (!parent->Server()) {
        return ResultSessionClosedByRemote;
    }

    // Signal the server session that new data is available
    return parent->Server()->HandleSyncRequest(std::move(thread), memory, core_timing);
}

} // namespace Kernel