Send clipboard data in a thread #4601

This commit is contained in:
Jerry (Xinyu Hou) 2015-05-15 16:05:20 -07:00 committed by Xinyu Hou
parent 44089d55e8
commit 4c36c08099
4 changed files with 19 additions and 66 deletions

View file

@ -20,9 +20,7 @@
#include "server/Server.h"
#include "synergy/FileChunker.h"
#include "synergy/ProtocolUtil.h"
#include "mt/Thread.h"
#include "io/IStream.h"
#include "base/TMethodJob.h"
#include "base/Log.h"
#include <sstream>
@ -124,11 +122,6 @@ ClientProxy1_5::setClipboard(ClipboardID id, const IClipboard* clipboard)
// send last message
ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataEnd, "\0");
// m_sendFileThread = new Thread(
// new TMethodJob<ClientProxy1_5>(
// this, &ClientProxy1_5::sendClipboardThread,
// reinterpret_cast<void*>(id)));
}
}
@ -209,52 +202,3 @@ ClientProxy1_5::dragInfoReceived()
m_server->dragInfoReceived(fileNum, content);
}
void
ClientProxy1_5::sendClipboardThread(void* data)
{
//size_t id = reinterpret_cast<size_t>(data);
//String clipboardData = m_clipboardData.at(id);
//int size = clipboardData.size();
//LOG((CLOG_DEBUG "sending clipboard %d to \"%s\" size=%d", id, getName().c_str(), size));
////TODO: refactor FileChunker
//// send first message (file size)
//std::stringstream ss;
//ss << size;
//String dataSize = ss.str();
//ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataStart, &dataSize);
//// send chunk messages with a fixed chunk size
//size_t sentLength = 0;
//size_t chunkSize = 2048;
//Stopwatch stopwatch;
//stopwatch.start();
//while (true) {
// if (stopwatch.getTime() > 0.1f) {
// // make sure we don't read too much from the mock data.
// if (sentLength + chunkSize > size) {
// chunkSize = size - sentLength;
// }
// char* chunk = new char[chunkSize];
// memcpy(chunk, clipboardData.substr(sentLength, chunkSize).c_str(), chunkSize);
// //String chunk(clipboardData.substr(sentLength, chunkSize).c_str(), chunkSize);
// //int sizetest = chunk.size();
// //sizetest++;
// //sizetest--;
// ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataChunk, chunk);
// sentLength += chunkSize;
// if (sentLength == size) {
// break;
// }
// stopwatch.reset();
// }
//}
//// send last message
//ProtocolUtil::writef(getStream(), kMsgDClipboard, id, 0, kDataEnd, "\0");
}