2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Removed unused PeerConnection::sendMessage(). Updated doc.
	* src/PeerConnection.cc
	* src/PeerConnection.h
pull/1/head
Tatsuhiro Tsujikawa 2010-03-04 16:27:42 +00:00
parent 8b73c2843f
commit 74cf8aa980
3 changed files with 8 additions and 33 deletions

View File

@ -1,3 +1,9 @@
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed unused PeerConnection::sendMessage(). Updated doc.
* src/PeerConnection.cc
* src/PeerConnection.h
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Reduced copying/std::string instantiation in sending/receiving

View File

@ -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<ARC4Encryptor>& encryptor,
const SharedHandle<ARC4Decryptor>& decryptor)
{

View File

@ -82,9 +82,8 @@ public:
~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);