LibNRG  0.0.1
Networking for Real-time Games library
 All Classes Files Functions Variables Friends
nrg_replay_server.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_REPLAY_SERVER_H
26 #define NRG_REPLAY_SERVER_H
27 #include "nrg_core.h"
28 #include "nrg_socket.h"
29 #include "nrg_server_state.h"
30 
31 #ifdef NRG_ENABLE_ZLIB_COMPRESSION
32  #include <zlib.h>
33 #else
34  typedef void* gzFile;
35 #endif
36 
37 namespace nrg {
38 
40 class ReplayServer {
41 public:
43  ReplayServer();
44 
46  bool openReplay(const char* filename);
47 
49  bool bind(const char* port);
50 
52  bool update();
53 
55  bool isReplayRunning() const;
56 private:
57  NetAddress bind_addr, client_addr;
58  UDPSocket sock;
59  Connection con;
60  ServerHandshakeState handshake;
61  gzFile file;
62  Packet buffer;
63  uint32_t local_timer, remote_timer;
64  int time_diff;
65  bool started;
66 };
67 
68 }
69 
70 #endif
Socket derivative specifically for the User-Datagram Protocol.
Definition: nrg_socket.h:112
bool isReplayRunning() const
Returns true if the ReplayServer is active.
Class for storing data to be sent / received across the network.
Definition: nrg_packet.h:58
bool bind(const char *port)
Binds the server to the specified local port.
bool openReplay(const char *filename)
Opens the specified replay file by name, returns true if it opened successfully.
Class that reads a replay file and acts as a local server, sending the packets in the file...
Definition: nrg_replay_server.h:40
Classes to wrap POSIX sockets.
Server-specific classes derived from State that are used internally.
ReplayServer()
Default constructor.
Combines both ConnectionIn and ConnectionOut into a single class.
Definition: nrg_connection.h:129
State for default handshake protocol, server-side.
Definition: nrg_server_state.h:36
Common defines and includes used by all the other nrg header files.
bool update()
Updates the ReplayServer, potentially sending new packets.
Class to wrap the various POSIX sockaddrs and resolve hostnames.
Definition: nrg_netaddress.h:32