From 7cbd3fdcb45838f90d4f7bb4be52f4ab4a0c4f86 Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Tue, 8 Dec 2015 12:27:55 -0800 Subject: [PATCH] Revert "Add keepAlive message before send file/clipboard data #4768" This reverts commit 5287c62540b277474603ea8a38c53b50cb8f4d52. --- src/lib/base/EventTypes.cpp | 1 + src/lib/base/EventTypes.h | 7 ++++++- src/lib/client/ServerProxy.cpp | 13 +++---------- src/lib/client/ServerProxy.h | 1 - src/lib/server/ClientProxy1_5.cpp | 7 ++++++- src/lib/server/ClientProxy1_6.cpp | 9 --------- src/lib/synergy/StreamChunker.cpp | 4 ++++ 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp index d30ae209e5..afa51900b5 100644 --- a/src/lib/base/EventTypes.cpp +++ b/src/lib/base/EventTypes.cpp @@ -198,3 +198,4 @@ REGISTER_EVENT(Clipboard, clipboardSending) REGISTER_EVENT(File, fileChunkSending) REGISTER_EVENT(File, fileRecieveCompleted) +REGISTER_EVENT(File, keepAlive) diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index d885adcd05..b10fb6b8b5 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -712,7 +712,8 @@ class FileEvents : public EventTypes { public: FileEvents() : m_fileChunkSending(Event::kUnknown), - m_fileRecieveCompleted(Event::kUnknown) { } + m_fileRecieveCompleted(Event::kUnknown), + m_keepAlive(Event::kUnknown) { } //! @name accessors //@{ @@ -723,9 +724,13 @@ class FileEvents : public EventTypes { //! Completed receiving a file Event::Type fileRecieveCompleted(); + //! Send a keep alive + Event::Type keepAlive(); + //@} private: Event::Type m_fileChunkSending; Event::Type m_fileRecieveCompleted; + Event::Type m_keepAlive; }; diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 615931d192..9c2b9c75a1 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -252,7 +252,9 @@ ServerProxy::parseMessage(const UInt8* code) } else if (memcmp(code, kMsgCKeepAlive, 4) == 0) { - keepAlive(); + // echo keep alives and reset alarm + ProtocolUtil::writef(m_stream, kMsgCKeepAlive); + resetKeepAliveAlarm(); } else if (memcmp(code, kMsgCNoop, 4) == 0) { @@ -890,21 +892,12 @@ ServerProxy::dragInfoReceived() void ServerProxy::handleClipboardSendingEvent(const Event& event, void*) { - keepAlive(); ClipboardChunk::send(m_stream, event.getData()); } -void ServerProxy::keepAlive() -{ - // echo keep alives and reset alarm - ProtocolUtil::writef(m_stream, kMsgCKeepAlive); - resetKeepAliveAlarm(); -} - void ServerProxy::fileChunkSending(UInt8 mark, char* data, size_t dataSize) { - keepAlive(); FileChunk::send(m_stream, mark, data, dataSize); } diff --git a/src/lib/client/ServerProxy.h b/src/lib/client/ServerProxy.h index 5133af501c..144fd000cc 100644 --- a/src/lib/client/ServerProxy.h +++ b/src/lib/client/ServerProxy.h @@ -107,7 +107,6 @@ class ServerProxy { void fileChunkReceived(); void dragInfoReceived(); void handleClipboardSendingEvent(const Event&, void*); - void keepAlive(); private: typedef EResult (ServerProxy::*MessageParser)(const UInt8*); diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp index e07c818731..2cdceb4003 100644 --- a/src/lib/server/ClientProxy1_5.cpp +++ b/src/lib/server/ClientProxy1_5.cpp @@ -35,10 +35,16 @@ ClientProxy1_5::ClientProxy1_5(const String& name, synergy::IStream* stream, Ser ClientProxy1_4(name, stream, server, events), m_events(events) { + + m_events->adoptHandler(m_events->forFile().keepAlive(), + this, + new TMethodEventJob(this, + &ClientProxy1_3::handleKeepAlive, NULL)); } ClientProxy1_5::~ClientProxy1_5() { + m_events->removeHandler(m_events->forFile().keepAlive(), this); } void @@ -52,7 +58,6 @@ ClientProxy1_5::sendDragInfo(UInt32 fileCount, const char* info, size_t size) void ClientProxy1_5::fileChunkSending(UInt8 mark, char* data, size_t dataSize) { - keepAlive(); FileChunk::send(getStream(), mark, data, dataSize); } diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp index cdfef01d99..bdd0f23fbc 100644 --- a/src/lib/server/ClientProxy1_6.cpp +++ b/src/lib/server/ClientProxy1_6.cpp @@ -50,12 +50,6 @@ ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard* clipboard) if (m_clipboard[id].m_dirty) { // this clipboard is now clean m_clipboard[id].m_dirty = false; - - // add keep alive message before we do clipboard copy - // in case there is a big data inside and time that would - // comsume will cause connecton being dropped - keepAlive(); - Clipboard::copy(&m_clipboard[id].m_clipboard, clipboard); String data = m_clipboard[id].m_clipboard.marshall(); @@ -72,9 +66,6 @@ ClientProxy1_6::setClipboard(ClipboardID id, const IClipboard* clipboard) void ClientProxy1_6::handleClipboardSendingEvent(const Event& event, void*) { - // add keep alive message before we send each clipboard data - keepAlive(); - ClipboardChunk::send(getStream(), event.getData()); } diff --git a/src/lib/synergy/StreamChunker.cpp b/src/lib/synergy/StreamChunker.cpp index bcf4a712bc..380a37a389 100644 --- a/src/lib/synergy/StreamChunker.cpp +++ b/src/lib/synergy/StreamChunker.cpp @@ -84,6 +84,8 @@ StreamChunker::sendFile( } if (sendStopwatch.getTime() > SEND_THRESHOLD) { + events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); + // make sure we don't read too much from the mock data. if (sentLength + chunkSize > size) { chunkSize = size - sentLength; @@ -149,6 +151,8 @@ StreamChunker::sendClipboard( } if (sendStopwatch.getTime() > SEND_THRESHOLD) { + events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); + // make sure we don't read too much from the mock data. if (sentLength + chunkSize > size) { chunkSize = size - sentLength;