ReplicaNet and RNLobby  1
CodeClient.h
1 /* START_LICENSE_HEADER
2 
3 Copyright (C) 2000 Martin Piper, original design and program code
4 Copyright (C) 2001 Replica Software
5 
6 This program file is copyright (C) Replica Software and can only be used under license.
7 For more information visit: http://www.replicanet.com/
8 Or email: info@replicanet.com
9 
10 END_LICENSE_HEADER */
11 #include "RNPlatform/Inc/MemoryTracking.h"
12 #ifndef _CODECLIENT_H_
13 #define _CODECLIENT_H_
14 #include "RNPlatform/Inc/Encryption.h"
15 #include "RNPlatform/Inc/ThreadClass.h"
16 #include "RNPlatform/Inc/Thread.h"
17 #include "RNXPSockets/Inc/XPSockets.h"
18 #include "RNLobby/Inc/CodeServer.h"
19 #include "RNPlatform/Inc/SysTime.h"
20 
21 namespace RNReplicaNet
22 {
23 
24 namespace RNLobby
25 {
26 
28 class CodeClient : private ThreadClass , private Thread
29 {
30 public:
31  CodeClient();
32  virtual ~CodeClient();
33 
41  bool Start(const char *code,const int nOnce1 = 0,const int nOnce2 = 0);
42 
46  bool Stop(bool hardware = false);
47 
50  bool GetCompleted(void);
51 
54  CodeServer::Reply GetReply(void);
55 
58  int GetUserSuppliedReply(void);
59 
61  void GetNOnces(int &nOnce1,int &nOnce2);
62 
67  void SetEncryptionKey(const void *data,const int length);
68 
71  void SetServer(const XPAddress &address);
72 
73 private:
74 
75  int ThreadEntry(void);
76  void CleanQuery(void);
77 
78  Encryption::Key mCryptoKey;
79 
80  volatile CodeServer::Reply mReply;
81  volatile bool mGotReply;
82  char *mCode;
83  XPSocketUrgent *mSend;
84  XPAddress mServerAddress;
85  int mUserSuppliedReply;
86  int mNOnce1;
87  int mNOnce2;
88  bool mServerAddressSet;
89 };
90 
91 } // namespace RNLobby
92 
93 } // namespace RNReplicaNet
94 
95 #endif
void SetServer(const XPAddress &address)
This code client queries for the validity of codes with the RNLobby::CodeServer.
Definition: CodeClient.h:28
Definition: Encryption.h:27
Definition: XPSocket.h:91
bool Stop(bool hardware=false)
void GetNOnces(int &nOnce1, int &nOnce2)
When there is a successful reply two random integers are generated by the CodeServer.
bool Start(const char *code, const int nOnce1=0, const int nOnce2=0)
void SetEncryptionKey(const void *data, const int length)
CodeServer::Reply GetReply(void)
Definition: XPSocketUrgentClass.h:26
Definition: ThreadClass.h:96
Definition: Thread.h:29