mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-21 10:01:42 +03:00
Added keep alive massge before each data transfer #4712
This commit is contained in:
parent
de49b46edd
commit
1659f9f018
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#define KEEP_ALIVE_THRESHOLD 1
|
|
||||||
#define SEND_THRESHOLD 0.005f
|
#define SEND_THRESHOLD 0.005f
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -73,9 +72,7 @@ StreamChunker::sendFile(
|
|||||||
// send chunk messages with a fixed chunk size
|
// send chunk messages with a fixed chunk size
|
||||||
size_t sentLength = 0;
|
size_t sentLength = 0;
|
||||||
size_t chunkSize = s_chunkSize;
|
size_t chunkSize = s_chunkSize;
|
||||||
Stopwatch keepAliveStopwatch;
|
|
||||||
Stopwatch sendStopwatch;
|
Stopwatch sendStopwatch;
|
||||||
keepAliveStopwatch.start();
|
|
||||||
sendStopwatch.start();
|
sendStopwatch.start();
|
||||||
file.seekg (0, std::ios::beg);
|
file.seekg (0, std::ios::beg);
|
||||||
|
|
||||||
@ -86,12 +83,9 @@ StreamChunker::sendFile(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keepAliveStopwatch.getTime() > KEEP_ALIVE_THRESHOLD) {
|
|
||||||
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
|
|
||||||
keepAliveStopwatch.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sendStopwatch.getTime() > SEND_THRESHOLD) {
|
if (sendStopwatch.getTime() > SEND_THRESHOLD) {
|
||||||
|
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
|
||||||
|
|
||||||
// make sure we don't read too much from the mock data.
|
// make sure we don't read too much from the mock data.
|
||||||
if (sentLength + chunkSize > size) {
|
if (sentLength + chunkSize > size) {
|
||||||
chunkSize = size - sentLength;
|
chunkSize = size - sentLength;
|
||||||
@ -146,9 +140,7 @@ StreamChunker::sendClipboard(
|
|||||||
// send clipboard chunk with a fixed size
|
// send clipboard chunk with a fixed size
|
||||||
size_t sentLength = 0;
|
size_t sentLength = 0;
|
||||||
size_t chunkSize = s_chunkSize;
|
size_t chunkSize = s_chunkSize;
|
||||||
Stopwatch keepAliveStopwatch;
|
|
||||||
Stopwatch sendStopwatch;
|
Stopwatch sendStopwatch;
|
||||||
keepAliveStopwatch.start();
|
|
||||||
sendStopwatch.start();
|
sendStopwatch.start();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -157,13 +149,10 @@ StreamChunker::sendClipboard(
|
|||||||
LOG((CLOG_DEBUG "clipboard transmission interrupted"));
|
LOG((CLOG_DEBUG "clipboard transmission interrupted"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keepAliveStopwatch.getTime() > KEEP_ALIVE_THRESHOLD) {
|
|
||||||
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
|
|
||||||
keepAliveStopwatch.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sendStopwatch.getTime() > SEND_THRESHOLD) {
|
if (sendStopwatch.getTime() > SEND_THRESHOLD) {
|
||||||
|
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
|
||||||
|
|
||||||
// make sure we don't read too much from the mock data.
|
// make sure we don't read too much from the mock data.
|
||||||
if (sentLength + chunkSize > size) {
|
if (sentLength + chunkSize > size) {
|
||||||
chunkSize = size - sentLength;
|
chunkSize = size - sentLength;
|
||||||
|
Loading…
Reference in New Issue
Block a user