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 boost::asio::io_context& ctx);
36
40
42
46
48 void connect();
49
51 void disconnect();
52
55 bool is_connected() const;
56
58
62
74 template <typename Type, typename Fn>
75 void on(Fn&& callback) {
76 network_->template on<Type>(std::forward<Fn>(callback));
77 }
78
79
83
92 template <typename Request>
93 void execute(const Request& req) {
94 network_->execute(req);
95 }
96
98
99 private:
100 std::unique_ptr<Steam::Messaging::CMClient> network_;
101};
102
103
104} // namespace Steam
void execute(const Request &req)
Send a command to the Steam CM server.
Definition client.hpp:93
void on(Fn &&callback)
Registers a callback for a specific CMClient event.
Definition client.hpp:75
~SteamClient()
Destructor Ensures the client disconnects from CM servers before destruction.
SteamClient(std::unique_ptr< Steam::Networking::IConnection > connection, boost::asio::io_context &ctx)
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.