From: Remi B. <els...@us...> - 2004-06-19 11:09:27
|
Update of /cvsroot/once/oncecode/src/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12922/client Modified Files: occlient.cpp occltcontmanager.cpp occltcontmanager.h Log Message: Allow client to disconnect from server and reconnect without closing client. Content manager broke it. Index: occltcontmanager.h =================================================================== RCS file: /cvsroot/once/oncecode/src/client/occltcontmanager.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** occltcontmanager.h 17 Jun 2004 17:37:43 -0000 1.10 --- occltcontmanager.h 19 Jun 2004 11:09:17 -0000 1.11 *************** *** 203,207 **** bool CanSendNewRequest() { return waiting_reply_from_server == false ! && downloaded_files.GetSize() == 0; } /** Purge file tree from outdated files. This must be called before saving --- 203,209 ---- bool CanSendNewRequest() { return waiting_reply_from_server == false ! && downloaded_files.GetSize() == 0 ! && clientsys->GetNetworkMgr()->IsConnected(); ! } /** Purge file tree from outdated files. This must be called before saving *************** *** 258,261 **** --- 260,271 ---- bool IsDirSubscribed(ocContentDir* dir); + /** Used by main ocClient class to notify the manager when we lost our + * connection to server. */ + void ConnectionToServerLost(); + + /** Used by main ocClient class to notify the manager when we connected + * to server. */ + void ConnectedToServer(); + /*********************** Handle messages **********************************/ bool HandleFilePart(ocFilePartMsg *msg); Index: occlient.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/client/occlient.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** occlient.cpp 17 Jun 2004 17:37:43 -0000 1.58 --- occlient.cpp 19 Jun 2004 11:09:17 -0000 1.59 *************** *** 300,303 **** --- 300,304 ---- current_area = area; awsmgr->Hide(); + content_manager->ConnectedToServer(); PrintMessage("Login successful, transfer to area %d.\n", area.GetAreaID()); } *************** *** 307,310 **** --- 308,312 ---- PrintMessage("Connection to server lost.\n"); + content_manager->ConnectionToServerLost(); display->Shutdown(); subscriptionmgr->ClearParts(); Index: occltcontmanager.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/client/occltcontmanager.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** occltcontmanager.cpp 17 Jun 2004 17:37:43 -0000 1.14 --- occltcontmanager.cpp 19 Jun 2004 11:09:17 -0000 1.15 *************** *** 169,175 **** } ! void ocFileListener::SubscriptionToDirEnd(ocContentDir*) { ! CS_ASSERT(0); } --- 169,180 ---- } ! void ocFileListener::SubscriptionToDirEnd(ocContentDir* dir) { ! bool was_ready = FilesAreReady(); ! ! ToggleSubscription(dir, false); ! ! if (was_ready) ! FilesNoMoreReady(); } *************** *** 602,603 **** --- 607,634 ---- return success; } + + void ocClientContentMgr::ConnectionToServerLost() + { + csHash<ocPartialContentFile*>::GlobalIterator it = + downloaded_files.GetIterator(); + while (it.HasNext()) { + ocPartialContentFile* pfile = it.Next(); + outdated_files.Push(pfile->content_file); + delete pfile; + } + downloaded_files.DeleteAll(); + + for (int i = 0; i < subscribed_dirs.Length(); i++) + { + for (int j = 0; j < listeners.Length(); j++) + listeners[j]->SubscriptionToDirEnd(subscribed_dirs[i]); + } + subscribed_dirs.Empty(); + + waiting_reply_from_server = false; + } + + void ocClientContentMgr::ConnectedToServer() + { + CheckNextRequest(); + } |