osb/source/application/discord/network_manager.h

64 lines
1.7 KiB
C
Raw Normal View History

2023-06-20 04:33:09 +00:00
#pragma once
#include "types.h"
namespace discord {
class NetworkManager final {
public:
~NetworkManager() = default;
2024-03-08 09:09:27 +00:00
/**
* Get the local peer ID for this process.
*/
2023-06-20 04:33:09 +00:00
void GetPeerId(NetworkPeerId* peerId);
2024-03-08 09:09:27 +00:00
/**
* Send pending network messages.
*/
2023-06-20 04:33:09 +00:00
Result Flush();
2024-03-08 09:09:27 +00:00
/**
* Open a connection to a remote peer.
*/
2023-06-20 04:33:09 +00:00
Result OpenPeer(NetworkPeerId peerId, char const* routeData);
2024-03-08 09:09:27 +00:00
/**
* Update the route data for a connected peer.
*/
2023-06-20 04:33:09 +00:00
Result UpdatePeer(NetworkPeerId peerId, char const* routeData);
2024-03-08 09:09:27 +00:00
/**
* Close the connection to a remote peer.
*/
2023-06-20 04:33:09 +00:00
Result ClosePeer(NetworkPeerId peerId);
2024-03-08 09:09:27 +00:00
/**
* Open a message channel to a connected peer.
*/
2023-06-20 04:33:09 +00:00
Result OpenChannel(NetworkPeerId peerId, NetworkChannelId channelId, bool reliable);
2024-03-08 09:09:27 +00:00
/**
* Close a message channel to a connected peer.
*/
2023-06-20 04:33:09 +00:00
Result CloseChannel(NetworkPeerId peerId, NetworkChannelId channelId);
2024-03-08 09:09:27 +00:00
/**
* Send a message to a connected peer over an opened message channel.
*/
2023-06-20 04:33:09 +00:00
Result SendMessage(NetworkPeerId peerId,
NetworkChannelId channelId,
std::uint8_t* data,
std::uint32_t dataLength);
Event<NetworkPeerId, NetworkChannelId, std::uint8_t*, std::uint32_t> OnMessage;
Event<char const*> OnRouteUpdate;
private:
friend class Core;
NetworkManager() = default;
NetworkManager(NetworkManager const& rhs) = delete;
NetworkManager& operator=(NetworkManager const& rhs) = delete;
NetworkManager(NetworkManager&& rhs) = delete;
NetworkManager& operator=(NetworkManager&& rhs) = delete;
IDiscordNetworkManager* internal_;
static IDiscordNetworkEvents events_;
};
} // namespace discord