forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
ClientMgr.h
1 #ifndef CLIENTMGR_H
2 #define CLIENTMGR_H
3 
4 #include "Forest.h"
5 #include "Packet.h"
6 #include "CtlPkt.h"
7 #include "Substrate.h"
8 #include "PacketStoreTs.h"
9 #include "ClientTable.h"
10 #include "NetBuffer.h"
11 #include "Queue.h"
12 #include "CpHandler.h"
13 //#include "IdMap.h"
14 //#include "UiSetPair.h"
15 #include <pthread.h>
16 #include <map>
17 
18 namespace forest {
19 
21 ipa_t myIp;
23 ipa_t rtrIp;
24 ipp_t rtrPort;
25 ipa_t nmIp;
27 char *dummyRecord;
28 int maxRecord;
29 
31 
35 
36 ofstream acctFile;
37 fstream clientFile;
38 pthread_mutex_t clientFileLock;
39 
42  UNDEF, NEWSESSION, CANCELSESSION, CONNECT_REC, DISCONNECT_REC
43 };
44 
45 static int const RECORD_SIZE = 256;
46 
47 bool init(ipa_t,ipa_t);
48 bool bootMe(ipa_t, ipa_t, fAdr_t&, fAdr_t&, fAdr_t&, ipa_t&, ipp_t&, uint64_t&);
49 
50 // handler tasks
51 void* handler(void *);
52 bool handleClient(int,CpHandler&);
53 bool handleConnDisc(pktx,CtlPkt&,CpHandler&);
54 
55 // methods that implement requests from remote clients
56 bool login(NetBuffer&,string&,string&);
57 bool newAccount(NetBuffer&,string&,string&);
58 void newSession(int, CpHandler&, NetBuffer&, string&, string&);
59 void getProfile(NetBuffer&, string&, string&);
60 void updateProfile(NetBuffer&, string&, string&);
61 void changePassword(NetBuffer&, string&, string&);
62 void uploadFile(string, int, NetBuffer&, string&, string&);
63 void getSessions(NetBuffer&, string&, string&);
64 void cancelSession(NetBuffer&, string&, CpHandler&, string&);
65 void cancelAllSessions(NetBuffer&, string&, CpHandler&, string&);
66 void addComtree(NetBuffer&, string&, string&);
67 
68 void writeRecord(int);
69 void writeAcctRecord(const string&, fAdr_t, ipa_t, fAdr_t, acctRecType);
70 
71 } // ends namespace
72 
73 #endif