vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::NetServer Class Reference

The authority's half of a NetSession: seats, the join handshake, commands in and snapshots out. More...

#include <net_server.h>

Public Types

using SpawnPlayer = std::function<EntityId(Scene&, ResourceManager&, PlayerId)>
 What a joining player is given, decided by the game.
using DespawnPlayer = std::function<void(Scene&, ResourceManager&, PlayerId, EntityId)>
 Undo what SpawnPlayer did.

Public Member Functions

void open (uint32_t maxPlayers)
 Start taking up to maxPlayers players, under a fresh join key.
void close ()
 Tell every player goodbye and forget them.
void receive (Scene &scene, ResourceManager &resources)
 Take every datagram that has arrived, then give back the seats that are going.
void beginTick (uint32_t tick)
 Hand every player the command its entity runs this tick.
void endTick (const Scene &scene, uint32_t tick)
 Remember where every player is, for judging a shot later.
void send (Scene &scene, uint32_t tick)
 Send every player who has answered its snapshot of this tick.
const InputCommand * commandFor (EntityId entity) const
 The command entity's player sent for this tick.
void rewind (Scene &scene, EntityId shooter)
 Put every player but shooter where shooter saw them.
void restore (Scene &scene)
 Put back exactly what rewind moved.
void forgetWorld ()
 Drop everything naming an entity; see NetSession::forgetWorld.

Detailed Description

The authority's half of a NetSession: seats, the join handshake, commands in and snapshots out.

Holds nothing outside a server's session; NetSession decides when it is asked.

Member Typedef Documentation

◆ SpawnPlayer

using Vkm::Engine::NetServer::SpawnPlayer = std::function<EntityId(Scene&, ResourceManager&, PlayerId)>

What a joining player is given, decided by the game.

Returns the entity that player owns; a null entity refuses the connection.

◆ DespawnPlayer

using Vkm::Engine::NetServer::DespawnPlayer = std::function<void(Scene&, ResourceManager&, PlayerId, EntityId)>

Undo what SpawnPlayer did.

Called when a player leaves, times out, or the session closes.

Member Function Documentation

◆ commandFor()

const InputCommand * Vkm::Engine::NetServer::commandFor ( EntityId entity) const

The command entity's player sent for this tick.

Parameters
entityThe entity about to be driven.
Returns
The command, or null when no player drives entity.

◆ rewind()

void Vkm::Engine::NetServer::rewind ( Scene & scene,
EntityId shooter )

Put every player but shooter where shooter saw them.

Parameters
sceneThe world to rewind.
shooterWhose moment is restored; a shooter no player drives is judged against the present.

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