group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
DiscoveryServer Class Reference

#include <DiscoveryServer.hpp>

Collaboration diagram for DiscoveryServer:
[legend]

Classes

struct  ServerInfo

Public Member Functions

bool start (uint16_t port, const ServerInfo &serverInfo, std::function< uint8_t()> playerCountFn=nullptr, std::function< uint32_t()> globalServerIdFn=nullptr)
 starts a thread that makes a UDP socket and broadcasts
void updateInfo (const ServerInfo &serverInfo)
void stop ()

Private Member Functions

void loop ()

Private Attributes

NET_DatagramSocket * socket = nullptr
std::atomic< bool > shouldStop {false}
std::thread broadcastThread
ServerInfo info
std::mutex infoMutex
std::function< uint8_t()> currentPlayersFn
std::function< uint32_t()> globalServerIdFn

Member Function Documentation

◆ loop()

void DiscoveryServer::loop ( )
private
Here is the caller graph for this function:

◆ start()

bool DiscoveryServer::start ( uint16_t port,
const ServerInfo & serverInfo,
std::function< uint8_t()> playerCountFn = nullptr,
std::function< uint32_t()> globalServerIdFn = nullptr )

starts a thread that makes a UDP socket and broadcasts

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void DiscoveryServer::stop ( )
Here is the caller graph for this function:

◆ updateInfo()

void DiscoveryServer::updateInfo ( const ServerInfo & serverInfo)
Here is the caller graph for this function:

Member Data Documentation

◆ broadcastThread

std::thread DiscoveryServer::broadcastThread
private

◆ currentPlayersFn

std::function<uint8_t()> DiscoveryServer::currentPlayersFn
private

◆ globalServerIdFn

std::function<uint32_t()> DiscoveryServer::globalServerIdFn
private

◆ info

ServerInfo DiscoveryServer::info
private

◆ infoMutex

std::mutex DiscoveryServer::infoMutex
private

◆ shouldStop

std::atomic<bool> DiscoveryServer::shouldStop {false}
private

◆ socket

NET_DatagramSocket* DiscoveryServer::socket = nullptr
private

The documentation for this class was generated from the following files: