mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-12-23 00:35:32 +00:00
Buffer incoming streamed data in the frontend
This commit is contained in:
parent
4d3ce45dc4
commit
d53603e211
|
@ -32,11 +32,13 @@ where
|
|||
Self: Sized,
|
||||
{
|
||||
/// Unwraps this object. See `unwrap()`.
|
||||
#[inline]
|
||||
fn log_unwrap(self) -> T {
|
||||
self.log_expect("Failed to unwrap")
|
||||
}
|
||||
|
||||
/// Unwraps this object, with a specified error message on failure. See `expect()`.
|
||||
#[inline]
|
||||
fn log_expect(self, msg: &str) -> T;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,19 @@ function stream_ajax(path, callback, successCallback, failCallback, data) {
|
|||
}
|
||||
});
|
||||
|
||||
var buffer = "";
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
if(req.readyState > 2) {
|
||||
var newData = req.responseText.substr(req.seenBytes);
|
||||
|
||||
var lines = newData.split("\n");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = lines[i].trim();
|
||||
buffer += newData;
|
||||
|
||||
var pointer;
|
||||
while ((pointer = newData.indexOf("\n")) >= 0) {
|
||||
var line = newData.substring(0, pointer).trim();
|
||||
newData = newData.substring(pointer + 1);
|
||||
|
||||
if (line.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue