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

Public Member Functions

 NetworkClient (NetworkManager &_manager, KapEngine::KEngine &_engine)
 
void connect (const std::string &ip, int port)
 Connect client to a NetworkServer by ip and port.
 
void disconnect ()
 Disconnect from server.
 
void networkEarlyUpdate ()
 NetworkEarlyUpdate. (we add this to the KapEngine in OnFixedUpdate)
 
bool isActive () const
 isActive is true while a client is isConnecting/isConnected. (= while the network is active)
 
bool isConnecting () const
 Check if client is connecting (before isConnected).
 
bool isConnected () const
 Check if client is connected (after isConnecting).
 
template<typename T , typename = std::enable_if<std::is_base_of<NetworkMessage, T>::value>>
void send (T &message)
 Send a NetworkMessage to the server.
 
template<typename T , typename = std::enable_if<std::is_base_of<NetworkMessage, T>::value>>
void registerHandler (std::function< void(const std::shared_ptr< NetworkConnectionToServer > &, 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 updateObject (unsigned int id)
 Update GameObject for all clients.
 
bool getExistingObject (unsigned int networkId, std::shared_ptr< KapEngine::GameObject > &gameObject)
 Get existing GameObject with networkId. (Spawned by server)
 

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: