From 74cf8aa980a51d2f9f83c84d31c4df5d3b2f8d36 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 4 Mar 2010 16:27:42 +0000 Subject: [PATCH] 2010-03-05 Tatsuhiro Tsujikawa Removed unused PeerConnection::sendMessage(). Updated doc. * src/PeerConnection.cc * src/PeerConnection.h --- ChangeLog | 6 ++++++ src/PeerConnection.cc | 30 ------------------------------ src/PeerConnection.h | 5 ++--- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75fb7a1c..3f992417 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-03-05 Tatsuhiro Tsujikawa + + Removed unused PeerConnection::sendMessage(). Updated doc. + * src/PeerConnection.cc + * src/PeerConnection.h + 2010-03-05 Tatsuhiro Tsujikawa Reduced copying/std::string instantiation in sending/receiving diff --git a/src/PeerConnection.cc b/src/PeerConnection.cc index a717f33e..af593edc 100644 --- a/src/PeerConnection.cc +++ b/src/PeerConnection.cc @@ -70,16 +70,6 @@ PeerConnection::~PeerConnection() delete [] resbuf; } -ssize_t PeerConnection::sendMessage(const unsigned char* data, - size_t dataLength) -{ - ssize_t writtenLength = sendData(data, dataLength, _encryptionEnabled); - if(logger->debug()) { - logger->debug("sent %d byte(s).", writtenLength); - } - return writtenLength; -} - void PeerConnection::pushStr(const std::string& data) { if(_encryptionEnabled) { @@ -249,26 +239,6 @@ void PeerConnection::readData(unsigned char* data, size_t& length, bool encrypti } } -ssize_t PeerConnection::sendData(const unsigned char* data, - size_t length, bool encryption) -{ - if(encryption) { - unsigned char temp[4096]; - const unsigned char* dptr = data; - size_t r = length; - while(r > 0) { - size_t s = std::min(r, sizeof(temp)); - _encryptor->encrypt(temp, s, dptr, s); - _socketBuffer.feedSendBuffer(std::string(&temp[0], &temp[s])); - dptr += s; - r -= s; - } - } else { - _socketBuffer.feedSendBuffer(std::string(&data[0], &data[length])); - } - return _socketBuffer.send(); -} - void PeerConnection::enableEncryption(const SharedHandle& encryptor, const SharedHandle& decryptor) { diff --git a/src/PeerConnection.h b/src/PeerConnection.h index a7b41f14..46719e66 100644 --- a/src/PeerConnection.h +++ b/src/PeerConnection.h @@ -81,10 +81,9 @@ public: PeerConnection(int32_t cuid, const SharedHandle& socket); ~PeerConnection(); - - // Returns the number of bytes written - ssize_t sendMessage(const unsigned char* data, size_t dataLength); + // Pushes data into send buffer. After this call, this object gets + // ownership of data, so caller must not delete or alter it. void pushBytes(unsigned char* data, size_t len); void pushStr(const std::string& data);