R-Type
R-Type project
KapMirror::NetworkServer Class Reference

Public Member Functions

 NetworkServer (NetworkManager &_manager, KapEngine::KEngine &_engine)
 
bool isActivated () const
 
void listen (int maxConnections, int port)
 Starts server and listens to incoming connections with max connections limit.
 
void shutdown ()
 Shuts down the server and disconnects all clients.
 
void networkEarlyUpdate () const
 NetworkEarlyUpdate. (we add this to the KapEngine in OnFixedUpdate)
 
template<typename T , typename = std::enable_if<std::is_base_of<NetworkMessage, T>::value>>
void sendToAll (T &message)
 Send a message to all clients which have joined the world (are ready).
 
template<typename T , typename = std::enable_if<std::is_base_of<NetworkMessage, T>::value>>
void sendToClient (T &message, unsigned int networkId)
 Send a message to a specific client.
 
void disconnectAll ()
 Disconnect all connections.
 
template<typename T , typename = std::enable_if<std::is_base_of<NetworkMessage, T>::value>>
void registerHandler (std::function< void(const std::shared_ptr< NetworkConnectionToClient > &, T &)> handler)
 Register a handler for a message type T.
 
template<typename T , typename = std::enable_if<std::is_base_of<NetworkMessage, T>::value>>
void unregisterHandler (T &message)
 Unregister a message handler of type T.
 
void spawnObject (const std::string &prefabName, KapEngine::SceneManagement::Scene &scene, const KapEngine::Tools::Vector3 &position, const std::function< void(const std::shared_ptr< KapEngine::GameObject > &)> &playload, std::shared_ptr< KapEngine::GameObject > &gameObject)
 Spawn new GameObject on specifics Scene for all clients. (only Prefab)
 
void spawnObject (const std::string &prefabName, std::size_t sceneId, const KapEngine::Tools::Vector3 &position, const std::function< void(const std::shared_ptr< KapEngine::GameObject > &)> &playload, std::shared_ptr< KapEngine::GameObject > &gameObject)
 Spawn new GameObject on specifics Scene for all clients. (only Prefab)
 
void spawnObject (const std::string &prefabName, const KapEngine::Tools::Vector3 &position, const std::function< void(const std::shared_ptr< KapEngine::GameObject > &)> &playload, std::shared_ptr< KapEngine::GameObject > &gameObject)
 Spawn new GameObject on current Scene for all clients. (only Prefab)
 
void spawnObject (const std::string &prefabName, const KapEngine::Tools::Vector3 &position, std::shared_ptr< KapEngine::GameObject > &gameObject)
 Spawn new GameObject on current Scene for all clients. (only Prefab)
 
void unSpawn (const std::shared_ptr< KapEngine::GameObject > &gameObject)
 This takes an object that has been spawned and un-spawns it. The object will be removed from clients.
 
void destroyObject (unsigned int networkId)
 Destroy GameObject corresponding of networkId for all clients.
 
void destroyObject (const std::shared_ptr< KapEngine::GameObject > &gameObject)
 Destroy GameObject for all clients.
 
void updateObject (unsigned int id)
 Update GameObject for all clients.
 
bool getExistingObject (unsigned int id, std::shared_ptr< KapEngine::GameObject > &gameObject)
 Get existing GameObject with networkId.
 

Public Attributes

Experimental::Action< void(std::shared_ptr< NetworkConnection >)> onConnectedEvent
 
Experimental::Action< void(std::shared_ptr< NetworkConnection >)> onDisconnectedEvent
 

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