mirror of https://github.com/aria2/aria2
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed unused PeerConnection::sendMessage(). Updated doc. * src/PeerConnection.cc * src/PeerConnection.hpull/1/head
parent
8b73c2843f
commit
74cf8aa980
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue