/* UserData :: username, ip, next user, prev user, stats Users :: AddUser(),AddUser(prev,next),RemoveUser(username) LoginManager listens for connections from clients. When a user wishes to login it handles the authentication. When the user is confirmed it calles Users::AddUser(thisUser) where thisUser is the UserData object for the new client. This causes the nextuser and prevuser pointers to be updated. LoginManager after detecting a login/out of a client, attempts to confirm this with the client and the next/prev users besides that client. If connections are made to both users and the ring is fixed, then the clients userdata on the server is removed and the other users updated to match. If either connection fails, we have a broken ring. Need to go into an error recovery mode. In error recovery mode: e.g. a -> b -> c -> d -> a c has dropped, we tried to call b and tell him to connect to d, but failed. Boot b from system as well, attempt to call a and connect to d. If a fails, boot a. Now only one user on network. a -> b -> d -> a Communicated with b ok and told them to talk to d, and vice versa. Recursive method. */ #ifndef USERS_AND_ABUSERS #define USERS_AND_ABUSERS #include "common.h" #include #include #include // extension of DB UserTable class to access mysql data about a user // and prevent duplication of data. class UserData : public wxObject { public: UserData(); UserData *next; UserData *prev; wxString username; // wxString ip; // ip address in string form? //CwxIPv4AddressEx m_addr; int id; time_t lastPing; time_t lastUpdate; float longitude; float latitude; wxString ip; int udp_port; int tcp_port; int png_port; wxString toString(); static int Compare(UserData *item1, UserData *item2, UserData *user); }; WX_DECLARE_OBJARRAY(UserData,Users); class UsersList : public Users { public: UserData * GetClosest(UserData *user); float GetDistance(UserData *item1, UserData *item2); UserData * Find(wxString username); private: }; extern UsersList *users; extern wxMutex users_mutex; #endif