mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
*** empty log message ***
This commit is contained in:
parent
563e041030
commit
493eb9c2d8
@ -43,12 +43,6 @@ enum receive_status {
|
|||||||
RS_eof
|
RS_eof
|
||||||
};
|
};
|
||||||
|
|
||||||
enum download_status {
|
|
||||||
D_error = -2,
|
|
||||||
D_timeout = -1,
|
|
||||||
D_success = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : DownloaderToken
|
// Class : DownloaderToken
|
||||||
// Description : Holds a request for the downloader.
|
// Description : Holds a request for the downloader.
|
||||||
@ -375,15 +369,12 @@ process_request() {
|
|||||||
int ret = download(tok->_file_name, tok->_file_dest, tok->_event_name,
|
int ret = download(tok->_file_name, tok->_file_dest, tok->_event_name,
|
||||||
tok->_first_byte, tok->_last_byte, tok->_total_bytes,
|
tok->_first_byte, tok->_last_byte, tok->_total_bytes,
|
||||||
tok->_partial_content, tok->_sync, tok->_id);
|
tok->_partial_content, tok->_sync, tok->_id);
|
||||||
if (ret == D_success) {
|
nassertr(tok->_event_name.empty() == false, false);
|
||||||
|
PT_Event return_event = new Event(tok->_event_name);
|
||||||
|
return_event->add_parameter(EventParameter((int)tok->_id));
|
||||||
|
if (ret == DS_success) {
|
||||||
_token_board->_done.insert(tok);
|
_token_board->_done.insert(tok);
|
||||||
|
return_event->add_parameter(EventParameter(DS_success));
|
||||||
// Throw a "done" event now.
|
|
||||||
if (!tok->_event_name.empty()) {
|
|
||||||
PT_Event done = new Event(tok->_event_name);
|
|
||||||
done->add_parameter(EventParameter((int)tok->_id));
|
|
||||||
throw_event(done);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (downloader_cat.is_debug()) {
|
if (downloader_cat.is_debug()) {
|
||||||
downloader_cat.debug()
|
downloader_cat.debug()
|
||||||
@ -391,12 +382,9 @@ process_request() {
|
|||||||
<< tok->_file_name << "\n";
|
<< tok->_file_name << "\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PT_Event failure = new Event(tok->_event_name);
|
return_event->add_parameter(EventParameter(ret));
|
||||||
failure->add_parameter(EventParameter((int)tok->_id));
|
|
||||||
failure->add_parameter(EventParameter(0));
|
|
||||||
failure->add_parameter(EventParameter(ret));
|
|
||||||
throw_event(failure);
|
|
||||||
}
|
}
|
||||||
|
throw_event(return_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -570,12 +558,12 @@ download(const string &file_name, Filename file_dest,
|
|||||||
if (downloader_cat.is_debug())
|
if (downloader_cat.is_debug())
|
||||||
downloader_cat.debug()
|
downloader_cat.debug()
|
||||||
<< "Downloader::download() - downloading is disabled" << endl;
|
<< "Downloader::download() - downloading is disabled" << endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we are still connected to the server
|
// Make sure we are still connected to the server
|
||||||
if (connect_to_server() == false)
|
if (connect_to_server() == false)
|
||||||
return D_error;
|
return DS_abort;
|
||||||
|
|
||||||
// Attempt to open the destination file
|
// Attempt to open the destination file
|
||||||
file_dest.set_binary();
|
file_dest.set_binary();
|
||||||
@ -588,7 +576,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - Error opening file: " << file_dest
|
<< "Downloader::download() - Error opening file: " << file_dest
|
||||||
<< " for writing" << endl;
|
<< " for writing" << endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send an HTTP request for the file to the server
|
// Send an HTTP request for the file to the server
|
||||||
@ -628,12 +616,12 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - send timed out after: "
|
<< "Downloader::download() - send timed out after: "
|
||||||
<< downloader_timeout_retries << " retries" << endl;
|
<< downloader_timeout_retries << " retries" << endl;
|
||||||
return D_timeout;
|
return DS_timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_ret == SS_error)
|
if (send_ret == SS_error)
|
||||||
return D_error;
|
return DS_abort;
|
||||||
|
|
||||||
// Create a download status to maintain download progress information
|
// Create a download status to maintain download progress information
|
||||||
DownloadStatus status(_buffer->_buffer, event_name, first_byte, last_byte,
|
DownloadStatus status(_buffer->_buffer, event_name, first_byte, last_byte,
|
||||||
@ -648,7 +636,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
_buffer_lock.lock();
|
_buffer_lock.lock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nassertr(_frequency > 0, D_error);
|
nassertr(_frequency > 0, DS_abort);
|
||||||
// If byte rate has changed, recompute read size and write buffer size
|
// If byte rate has changed, recompute read size and write buffer size
|
||||||
if (_new_byte_rate > 0) {
|
if (_new_byte_rate > 0) {
|
||||||
_read_size = (int)ceil(_new_byte_rate * _frequency);
|
_read_size = (int)ceil(_new_byte_rate * _frequency);
|
||||||
@ -671,7 +659,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - failed to flush buffer during "
|
<< "Downloader::download() - failed to flush buffer during "
|
||||||
<< "resize" << endl;
|
<< "resize" << endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +692,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - Error reading from socket: "
|
<< "Downloader::download() - Error reading from socket: "
|
||||||
<< strerror(errno) << endl;
|
<< strerror(errno) << endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
|
|
||||||
case RS_timeout:
|
case RS_timeout:
|
||||||
|
|
||||||
@ -718,10 +706,10 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - write to disk failed after "
|
<< "Downloader::download() - write to disk failed after "
|
||||||
<< "timeout!" << endl;
|
<< "timeout!" << endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return D_timeout;
|
return DS_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
case RS_success:
|
case RS_success:
|
||||||
@ -750,8 +738,8 @@ download(const string &file_name, Filename file_dest,
|
|||||||
// when the download is complete
|
// when the download is complete
|
||||||
_connected = false;
|
_connected = false;
|
||||||
if (ret == false)
|
if (ret == false)
|
||||||
return D_error;
|
return DS_abort;
|
||||||
return D_success;
|
return DS_success;
|
||||||
} else {
|
} else {
|
||||||
if (downloader_cat.is_debug())
|
if (downloader_cat.is_debug())
|
||||||
downloader_cat.debug()
|
downloader_cat.debug()
|
||||||
@ -765,7 +753,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - Unknown return value from "
|
<< "Downloader::download() - Unknown return value from "
|
||||||
<< "attempt_read() : " << ret << endl;
|
<< "attempt_read() : " << ret << endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
|
|
||||||
} // switch(ret)
|
} // switch(ret)
|
||||||
|
|
||||||
@ -777,7 +765,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
downloader_cat.error()
|
downloader_cat.error()
|
||||||
<< "Downloader::download() - Dropped out of for loop without returning!"
|
<< "Downloader::download() - Dropped out of for loop without returning!"
|
||||||
<< endl;
|
<< endl;
|
||||||
return D_error;
|
return DS_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -968,6 +956,7 @@ write_to_disk(DownloadStatus &status) {
|
|||||||
if (!status._event_name.empty()) {
|
if (!status._event_name.empty()) {
|
||||||
PT_Event write_event = new Event(status._event_name);
|
PT_Event write_event = new Event(status._event_name);
|
||||||
write_event->add_parameter(EventParameter((int)status._id));
|
write_event->add_parameter(EventParameter((int)status._id));
|
||||||
|
write_event->add_parameter(EventParameter(DS_write));
|
||||||
write_event->add_parameter(EventParameter(status._total_bytes_written));
|
write_event->add_parameter(EventParameter(status._total_bytes_written));
|
||||||
throw_event(write_event);
|
throw_event(write_event);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,12 @@ class DownloaderToken;
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDAEXPRESS Downloader : public AsyncUtility {
|
class EXPCL_PANDAEXPRESS Downloader : public AsyncUtility {
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
|
enum DownloadCode {
|
||||||
|
DS_write = 2,
|
||||||
|
DS_success = 1,
|
||||||
|
DS_abort = -1,
|
||||||
|
DS_timeout = -2
|
||||||
|
};
|
||||||
Downloader(void);
|
Downloader(void);
|
||||||
//Downloader(PT(Buffer) buffer);
|
//Downloader(PT(Buffer) buffer);
|
||||||
virtual ~Downloader(void);
|
virtual ~Downloader(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user