/* RemoteClient.hpp Author: Patrick Baggett , James Russell Created: 12/2/2013 Purpose: Network peer as seen by a running simulation. May refer to either a client or another server instance. License: Copyright 2013, 762 Studios. */ #ifndef __ZREMOTEPEER_HPP #define __ZREMOTEPEER_HPP #include class ZRemotePeer { public: // the client state enum PeerState { AVAILABLE, JOINING, CONNECTED, CONNECTED_LOCAL, DISCONNECTED }; // c'tor ZRemotePeer() : bIsClient(true), State(AVAILABLE), Peer(NULL) { } // getters cID GetId() const { return Id; } PeerState GetState() const { return State; } bool IsClient() const { return bIsClient; } const char* GetName() const { return Name; } const char* GetHost() const { return Host; } ENetPeer* GetPeer() { return Peer; } // setters void SetId(cID id) { Id = id; } void SetState(PeerState cs) { State = cs; } void SetClient(bool isClient) { bIsClient = isClient; } void SetName(const char* name) { strcpy(Name, name); } void SetHostIP(const char* host) { strcpy(Host, host); } void SetPeer(ENetPeer* newPeer) { Peer = newPeer; } // resets this peer object (must be called to reuse object and connection id) void Reset() { SetPeer(NULL); SetState(AVAILABLE); SetName(""); SetHostIP(""); SetClient(true); } private: cID Id; // id of this connection assigned by network service ENetPeer* Peer; // peer object PeerState State; // overall state bool bIsClient; // true if this connects to a client char Host[ZSIM_NETWORK_MAX_HOST_LENGTH]; // host name in readable format char Name[ZSIM_NETWORK_MAX_NAME_LENGTH]; // network 'name' (unique among network peers) }; #endif