steam-min-cpp
Loading...
Searching...
No Matches
connection.hpp
Go to the documentation of this file.
1
3
4#pragma once
5#include <vector>
6#include <cstdint>
7#include <functional>
8
9namespace Steam::Networking {
10
12 enum class ConnectionState {
13 DISCONNECTED,
14 CONNECTING,
15 CONNECTED
16 };
17
24 public:
25
26 virtual ~IConnection() = default;
27
29 virtual ConnectionState state() const = 0;
30
32 inline bool is_connected() const {
33 return state() == ConnectionState::CONNECTED;
34 }
35
40 virtual void network_connect() = 0;
41
46 virtual void network_close() = 0;
47
51 virtual void async_send(const std::vector<uint8_t>& data) = 0;
52
59 virtual void set_on_frame(
60 std::function<void(std::vector<uint8_t>)> handler
61 ) = 0;
62 };
63}
Transport interface used by the CM networking client.
Definition connection.hpp:23
virtual void set_on_frame(std::function< void(std::vector< uint8_t >)> handler)=0
Register a frame receive handler.
bool is_connected() const
Check whether the transport is connected.
Definition connection.hpp:32
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:12