RavEngine
Loading...
Searching...
No Matches
RavEngine::NetworkServer Class Reference
Inheritance diagram for RavEngine::NetworkServer:
[legend]
Collaboration diagram for RavEngine::NetworkServer:
[legend]

Public Member Functions

void Start (uint16_t port)
 
void Stop ()
 
void SpawnEntity (World *, ctti_t, Entity, const uuids::uuid &)
 
void DestroyEntity (const uuids::uuid &)
 
void SendMessageToAllClients (const std::string_view &msg, Reliability mode) const
 
void SendMessageToClient (const std::string_view &msg, HSteamNetConnection connection, Reliability mode) const
 
void SendMessageToAllClientsExcept (const std::string_view &msg, HSteamNetConnection connection, Reliability mode) const
 
void DisconnectClient (HSteamNetConnection con, int reason, const char *msg_optional=nullptr)
 
void ChangeOwnership (HSteamNetConnection newOwner, ComponentHandle< NetworkIdentity > object)
 
std::string CreateSpawnCommand (const uuids::uuid &id, ctti_t type, std::string_view &worldID)
 
std::string CreateDestroyCommand (const uuids::uuid &id)
 
constexpr const decltype(clients) & GetClients ()
 

Static Public Member Functions

static void SteamNetConnectionStatusChanged (SteamNetConnectionStatusChangedCallback_t *)
 

Public Attributes

Function< void(HSteamNetConnection)> OnClientConnecting
 
Function< void(HSteamNetConnection)> OnClientConnected
 
Function< void(HSteamNetConnection)> OnClientDisconnected
 

Protected Member Functions

void OnRPC (const std::string_view &cmd, HSteamNetConnection)
 
void OnSteamNetConnectionStatusChanged (SteamNetConnectionStatusChangedCallback_t *)
 
void HandleDisconnect (HSteamNetConnection)
 
void ServerTick ()
 
void SynchronizeWorldToClient (HSteamNetConnection connection, const std::string_view &in_message)
 

Protected Attributes

ISteamNetworkingSockets * net_interface = nullptr
 
HSteamListenSocket listenSocket = k_HSteamListenSocket_Invalid
 
HSteamNetPollGroup pollGroup = k_HSteamNetPollGroup_Invalid
 
locked_node_hashset< HSteamNetConnection, SpinLock > clients
 
UnorderedMap< HSteamNetConnection, UnorderedSet< ComponentHandle< NetworkIdentity > > > OwnershipTracker
 
- Protected Attributes inherited from RavEngine::NetworkBase
std::thread worker
 
std::atomic< bool > workerIsRunning = false
 
std::atomic< bool > workerHasStopped = true
 
locked_node_hashmap< uuids::uuid, Entity, SpinLock > NetworkIdentities
 

Static Protected Attributes

static NetworkServer * currentServer = nullptr
 

Additional Inherited Members

- Public Types inherited from RavEngine::NetworkBase
enum  Reliability { Unreliable = k_nSteamNetworkingSend_Unreliable , Reliable = k_nSteamNetworkingSend_Reliable }
 

Member Function Documentation

◆ ChangeOwnership()

void RavEngine::NetworkServer::ChangeOwnership ( HSteamNetConnection  newOwner,
ComponentHandle< NetworkIdentity >  object 
)

Change the ownership of a networked object

Parameters
newOwnerthe connection handle for the new owner. Use Invalid to make the server owner
objectthe networkidentity to udpate the ownership of

◆ DisconnectClient()

void RavEngine::NetworkServer::DisconnectClient ( HSteamNetConnection  con,
int  reason,
const char *  msg_optional = nullptr 
)

Disconnect a client from the server

Parameters
theconnection handle to disconnect
reasonan integer specifying the reason. This is user-defined.
msg_optionalan optional string message to provide which will be received on the client.

◆ GetClients()

constexpr const decltype(clients) & RavEngine::NetworkServer::GetClients ( )
inlineconstexpr

Get the internal client structure. Note that to track application-specific client data, create your own datastructure and add event listeners to the OnConnecting, Ondisconnected, etc functions and track it yourself.


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