steam-min-cpp
Loading...
Searching...
No Matches
connection.hpp
Go to the documentation of this file.
1
3
4#pragma once
5#include <cstdint>
6#include <functional>
7#include <string>
8#include <vector>
9
10namespace Steam::Networking {
11
13enum class ConnectionState { DISCONNECTED, CONNECTING, CONNECTED };
14
21 public:
22 virtual ~IConnection() = default;
23
25 virtual ConnectionState state() const = 0;
26
28 inline bool is_connected() const {
29 return state() == ConnectionState::CONNECTED;
30 }
31
36 virtual void network_connect() = 0;
37
42 virtual void network_close() = 0;
43
47 virtual void async_send(const std::vector<uint8_t>& data) = 0;
48
55 virtual void set_on_frame(
56 std::function<void(std::vector<uint8_t>)> handler) = 0;
57
63 virtual void set_on_disconnect(
64 std::function<void(const std::string& reason)> handler) = 0;
65};
66} // namespace Steam::Networking
Transport interface used by the CM networking client.
Definition connection.hpp:20
virtual void set_on_frame(std::function< void(std::vector< uint8_t >)> handler)=0
Register a frame receive handler.
virtual void set_on_disconnect(std::function< void(const std::string &reason)> handler)=0
Register a disconect handler.
bool is_connected() const
Check whether the transport is connected.
Definition connection.hpp:28
virtual ConnectionState state() const =0
Retrieve the current connection state.
virtual void network_connect()=0
Initiate the network connection.
virtual void network_close()=0
Close the active connection.
virtual void async_send(const std::vector< uint8_t > &data)=0
Send a raw message frame.
ConnectionState
Connection lifecycle state.
Definition connection.hpp:13