steam-min-cpp
Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <memory>
8#include <steamclient/network/cmclient.hpp>
9#include <typeindex>
10
11namespace Steam {
12
26 public:
30
34 SteamClient(std::unique_ptr<Steam::Networking::IConnection> connection);
35
39
41
45
47 void connect();
48
50 void disconnect();
51
54 bool is_connected() const;
55
57
61
73 template <typename Type, typename Fn>
74 void on(Fn&& callback) {
75 network_->template on<Type>(std::forward<Fn>(callback));
76 }
77
78
82
91 template <typename Request>
92 void execute(const Request& req) {
93 network_->execute(req);
94 }
95
97
98 private:
99 std::unique_ptr<Steam::Messaging::CMClient> network_;
100};
101
102
103} // namespace Steam
void execute(const Request &req)
Send a command to the Steam CM server.
Definition client.hpp:92
void on(Fn &&callback)
Registers a callback for a specific CMClient event.
Definition client.hpp:74
~SteamClient()
Destructor Ensures the client disconnects from CM servers before destruction.
SteamClient(std::unique_ptr< Steam::Networking::IConnection > connection)
Construct a Steam client using a specific connection implementation.
bool is_connected() const
Check whether the client is currently connected.
void disconnect()
Disconnect from the current Steam CM server session.
void connect()
Establish a session with a Steam CM server.
Abstract transport interface used by the Steam networking layer.