LibNRG  0.0.1
Networking for Real-time Games library
 All Classes Files Functions Variables Friends
nrg_player.h
Go to the documentation of this file.
1 /*
2  LibNRG - Networking for Real-time Games
3 
4  Copyright (C) 2012-2014 Alex Baines <alex@abaines.me.uk>
5 
6  This software is provided 'as-is', without any express or implied
7  warranty. In no event will the authors be held liable for any damages
8  arising from the use of this software.
9 
10  Permission is granted to anyone to use this software for any purpose,
11  including commercial applications, and to alter it and redistribute it
12  freely, subject to the following restrictions:
13 
14  1. The origin of this software must not be misrepresented; you must not
15  claim that you wrote the original software. If you use this software
16  in a product, an acknowledgment in the product documentation would be
17  appreciated but is not required.
18  2. Altered source versions must be plainly marked as such, and must not be
19  misrepresented as being the original software.
20  3. This notice may not be removed or altered from any source distribution.
21 */
25 #ifndef NRG_PLAYER_H
26 #define NRG_PLAYER_H
27 #include "nrg_core.h"
28 #include "nrg_message.h"
29 namespace nrg {
30 
31 class Server;
32 
34 struct Player {
36  virtual uint16_t getID() const = 0;
37 
39  virtual void kick(const char* reason) = 0;
40 
42  virtual const Server* getServer() const = 0;
43 
45  virtual const NetAddress& getRemoteAddress() const = 0;
46 
48  virtual void registerMessageHandler(MessageBase&&) = 0;
49 
51  virtual void registerMessageHandler(const MessageBase&) = 0;
52 
54  virtual void sendMessage(const MessageBase& m) = 0;
55 
57  virtual bool isConnected() const = 0;
58 
60  virtual int getPing() const = 0;
61 
63  virtual ~Player(){}
64 };
65 
66 }
67 
68 #endif
virtual const NetAddress & getRemoteAddress() const =0
Returns the address the Client associated with this Player is connecting from.
Abstract base class for Message.
Definition: nrg_message.h:36
Contains Message classes and functionality for two-way RPC between Server and Client.
Represents a connected client on the server.
Definition: nrg_player.h:34
virtual int getPing() const =0
Returns the round-trip latency of this player.
The main server-side class of the library.
Definition: nrg_server.h:44
virtual void kick(const char *reason)=0
Kick the player from the server, sending them a reason why.
virtual uint16_t getID() const =0
Returns the library-assigned player's ID.
virtual ~Player()
Default destructor.
Definition: nrg_player.h:63
virtual const Server * getServer() const =0
Returns the server associated with this Player.
virtual bool isConnected() const =0
Returns true if this player is connected to a Server.
virtual void registerMessageHandler(MessageBase &&)=0
Register a Message containing a callback with this Player (R-Value reference version) ...
virtual void sendMessage(const MessageBase &m)=0
Send the player a Message with the contents specified in m.
Common defines and includes used by all the other nrg header files.
Class to wrap the various POSIX sockaddrs and resolve hostnames.
Definition: nrg_netaddress.h:32