aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver/Server
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-07-27 14:59:46 +0200
committerShauren <shauren.trinity@gmail.com>2014-07-27 14:59:46 +0200
commite77c0b6ed4516c09c648a6443b054b8b9e1edcf1 (patch)
tree68fdd1e6a6995f211292b494c7352ed207fe1a7c /src/server/authserver/Server
parent6699d969f3114b60109288caebee7b5d7d86b61e (diff)
Core/Network: Allow storing any packet types in Socket write queue to reduce the amount of copying going on
Diffstat (limited to 'src/server/authserver/Server')
-rw-r--r--src/server/authserver/Server/AuthSession.cpp10
-rw-r--r--src/server/authserver/Server/AuthSession.h9
2 files changed, 8 insertions, 11 deletions
diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp
index cc5dc8cbb1b..697fe027f5e 100644
--- a/src/server/authserver/Server/AuthSession.cpp
+++ b/src/server/authserver/Server/AuthSession.cpp
@@ -18,7 +18,6 @@
#include "AuthSession.h"
#include "Log.h"
-#include "ByteBuffer.h"
#include "AuthCodes.h"
#include "Database/DatabaseEnv.h"
#include "SHA1.h"
@@ -173,19 +172,16 @@ void AuthSession::ReadDataHandler(boost::system::error_code error, size_t transf
CloseSocket();
}
-void AuthSession::AsyncWrite(ByteBuffer const& packet)
+void AuthSession::AsyncWrite(ByteBuffer& packet)
{
- std::vector<uint8> data(packet.size());
- std::memcpy(data.data(), packet.contents(), packet.size());
-
std::lock_guard<std::mutex> guard(_writeLock);
bool needsWriteStart = _writeQueue.empty();
- _writeQueue.push(std::move(data));
+ _writeQueue.push(std::move(packet));
if (needsWriteStart)
- AsyncWrite(_writeQueue.front());
+ Base::AsyncWrite(_writeQueue.front());
}
bool AuthSession::HandleLogonChallenge()
diff --git a/src/server/authserver/Server/AuthSession.h b/src/server/authserver/Server/AuthSession.h
index eedffb86ff8..822f3c334fc 100644
--- a/src/server/authserver/Server/AuthSession.h
+++ b/src/server/authserver/Server/AuthSession.h
@@ -22,16 +22,17 @@
#include "Common.h"
#include "Socket.h"
#include "BigNumber.h"
+#include "ByteBuffer.h"
#include <memory>
#include <boost/asio/ip/tcp.hpp>
using boost::asio::ip::tcp;
struct AuthHandler;
-class ByteBuffer;
-class AuthSession : public Socket<AuthSession>
+class AuthSession : public Socket<AuthSession, ByteBuffer>
{
+ typedef Socket<AuthSession, ByteBuffer> Base;
public:
static std::unordered_map<uint8, AuthHandler> InitHandlers();
@@ -47,8 +48,8 @@ public:
AsyncReadHeader();
}
- using Socket<AuthSession>::AsyncWrite;
- void AsyncWrite(ByteBuffer const& packet);
+ using Base::AsyncWrite;
+ void AsyncWrite(ByteBuffer& packet);
protected:
void ReadHeaderHandler(boost::system::error_code error, size_t transferedBytes) override;