mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Network: Socket refactors
* Devirtualize calls to Read and Update by marking concrete implementations as final * Removed derived class template argument * Specialize boost::asio::basic_stream_socket for boost::asio::io_context instead of type-erased any_io_executor * Make socket initialization easier composable (before entering Read loop) * Remove use of deprecated boost::asio::null_buffers and boost::beast::ssl_stream
This commit is contained in:
@@ -29,9 +29,11 @@
|
||||
|
||||
void RASession::Start()
|
||||
{
|
||||
_socket.non_blocking(false);
|
||||
|
||||
// wait 1 second for active connections to send negotiation request
|
||||
for (int counter = 0; counter < 10 && _socket.available() == 0; counter++)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
std::this_thread::sleep_for(100ms);
|
||||
|
||||
// Check if there are bytes available, if they are, then the client is requesting the negotiation
|
||||
if (_socket.available() > 0)
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __RASESSION_H__
|
||||
#define __RASESSION_H__
|
||||
#ifndef TRINITYCORE_RA_SESSION_H
|
||||
#define TRINITYCORE_RA_SESSION_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "Socket.h"
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <future>
|
||||
@@ -29,7 +30,7 @@ const size_t bufferSize = 4096;
|
||||
class RASession : public std::enable_shared_from_this <RASession>
|
||||
{
|
||||
public:
|
||||
RASession(boost::asio::ip::tcp::socket&& socket) : _socket(std::move(socket)), _commandExecuting(nullptr)
|
||||
RASession(Trinity::Net::IoContextTcpSocket&& socket) : _socket(std::move(socket)), _commandExecuting(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ private:
|
||||
static void CommandPrint(void* callbackArg, std::string_view text);
|
||||
static void CommandFinished(void* callbackArg, bool);
|
||||
|
||||
boost::asio::ip::tcp::socket _socket;
|
||||
Trinity::Net::IoContextTcpSocket _socket;
|
||||
boost::asio::streambuf _readBuffer;
|
||||
boost::asio::streambuf _writeBuffer;
|
||||
std::promise<void>* _commandExecuting;
|
||||
|
||||
Reference in New Issue
Block a user