mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-19 08:51:41 +03:00
Inserted keep alive msg among data transfer #4584
This commit is contained in:
parent
bbf53bb9b8
commit
756c3b4463
@ -29,6 +29,8 @@ public:
|
|||||||
// IClient overrides
|
// IClient overrides
|
||||||
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
|
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
|
||||||
|
|
||||||
|
void handleKeepAlive(const Event&, void*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ClientProxy overrides
|
// ClientProxy overrides
|
||||||
virtual bool parseMessage(const UInt8* code);
|
virtual bool parseMessage(const UInt8* code);
|
||||||
@ -39,9 +41,6 @@ protected:
|
|||||||
virtual void removeHeartbeatTimer();
|
virtual void removeHeartbeatTimer();
|
||||||
virtual void keepAlive();
|
virtual void keepAlive();
|
||||||
|
|
||||||
private:
|
|
||||||
void handleKeepAlive(const Event&, void*);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_keepAliveRate;
|
double m_keepAliveRate;
|
||||||
EventQueueTimer* m_keepAliveTimer;
|
EventQueueTimer* m_keepAliveTimer;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "synergy/StreamChunker.h"
|
#include "synergy/StreamChunker.h"
|
||||||
#include "synergy/ProtocolUtil.h"
|
#include "synergy/ProtocolUtil.h"
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
|
#include "base/TMethodEventJob.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -34,10 +35,16 @@ ClientProxy1_5::ClientProxy1_5(const String& name, synergy::IStream* stream, Ser
|
|||||||
ClientProxy1_4(name, stream, server, events),
|
ClientProxy1_4(name, stream, server, events),
|
||||||
m_events(events)
|
m_events(events)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_events->adoptHandler(m_events->forFile().keepAlive(),
|
||||||
|
this,
|
||||||
|
new TMethodEventJob<ClientProxy1_3>(this,
|
||||||
|
&ClientProxy1_3::handleKeepAlive, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientProxy1_5::~ClientProxy1_5()
|
ClientProxy1_5::~ClientProxy1_5()
|
||||||
{
|
{
|
||||||
|
m_events->removeHandler(m_events->forFile().keepAlive(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -81,7 +88,7 @@ ClientProxy1_5::fileChunkReceived()
|
|||||||
|
|
||||||
|
|
||||||
if (result == kFinish) {
|
if (result == kFinish) {
|
||||||
m_events->addEvent(Event(m_events->forIScreen().fileRecieveCompleted(), server));
|
m_events->addEvent(Event(m_events->forFile().fileRecieveCompleted(), server));
|
||||||
}
|
}
|
||||||
else if (result == kStart) {
|
else if (result == kStart) {
|
||||||
String filename = server->getFakeDragFileList().at(0).getFilename();
|
String filename = server->getFakeDragFileList().at(0).getFilename();
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#define PAUSE_TIME_HACK 0.1f
|
#define KEEP_ALIVE_THRESHOLD 1
|
||||||
|
#define SEND_THRESHOLD 0.005f
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -67,14 +68,17 @@ StreamChunker::sendFile(
|
|||||||
String fileSize = synergy::string::sizeTypeToString(size);
|
String fileSize = synergy::string::sizeTypeToString(size);
|
||||||
FileChunk* sizeMessage = FileChunk::start(fileSize);
|
FileChunk* sizeMessage = FileChunk::start(fileSize);
|
||||||
|
|
||||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, sizeMessage));
|
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, sizeMessage));
|
||||||
|
|
||||||
// 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 stopwatch;
|
Stopwatch keepAliveStopwatch;
|
||||||
stopwatch.start();
|
Stopwatch sendStopwatch;
|
||||||
|
keepAliveStopwatch.start();
|
||||||
|
sendStopwatch.start();
|
||||||
file.seekg (0, std::ios::beg);
|
file.seekg (0, std::ios::beg);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (s_interruptFile) {
|
if (s_interruptFile) {
|
||||||
s_interruptFile = false;
|
s_interruptFile = false;
|
||||||
@ -82,7 +86,12 @@ StreamChunker::sendFile(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopwatch.getTime() > PAUSE_TIME_HACK) {
|
if (keepAliveStopwatch.getTime() > KEEP_ALIVE_THRESHOLD) {
|
||||||
|
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
|
||||||
|
keepAliveStopwatch.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendStopwatch.getTime() > SEND_THRESHOLD) {
|
||||||
// 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;
|
||||||
@ -94,7 +103,7 @@ StreamChunker::sendFile(
|
|||||||
FileChunk* fileChunk = FileChunk::data(data, chunkSize);
|
FileChunk* fileChunk = FileChunk::data(data, chunkSize);
|
||||||
delete[] chunkData;
|
delete[] chunkData;
|
||||||
|
|
||||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, fileChunk));
|
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, fileChunk));
|
||||||
|
|
||||||
sentLength += chunkSize;
|
sentLength += chunkSize;
|
||||||
file.seekg (sentLength, std::ios::beg);
|
file.seekg (sentLength, std::ios::beg);
|
||||||
@ -103,14 +112,14 @@ StreamChunker::sendFile(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch.reset();
|
sendStopwatch.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send last message
|
// send last message
|
||||||
FileChunk* end = FileChunk::end();
|
FileChunk* end = FileChunk::end();
|
||||||
|
|
||||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, end));
|
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, end));
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
@ -137,8 +146,10 @@ 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 stopwatch;
|
Stopwatch keepAliveStopwatch;
|
||||||
stopwatch.start();
|
Stopwatch sendStopwatch;
|
||||||
|
keepAliveStopwatch.start();
|
||||||
|
sendStopwatch.start();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (s_interruptClipboard) {
|
if (s_interruptClipboard) {
|
||||||
@ -147,7 +158,12 @@ StreamChunker::sendClipboard(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopwatch.getTime() > PAUSE_TIME_HACK) {
|
if (keepAliveStopwatch.getTime() > KEEP_ALIVE_THRESHOLD) {
|
||||||
|
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
|
||||||
|
keepAliveStopwatch.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendStopwatch.getTime() > SEND_THRESHOLD) {
|
||||||
// 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;
|
||||||
@ -159,12 +175,11 @@ StreamChunker::sendClipboard(
|
|||||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));
|
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));
|
||||||
|
|
||||||
sentLength += chunkSize;
|
sentLength += chunkSize;
|
||||||
|
|
||||||
if (sentLength == size) {
|
if (sentLength == size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch.reset();
|
sendStopwatch.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user