TrinityCore
Loading...
Searching...
No Matches
RASession.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITYCORE_RA_SESSION_H
19#define TRINITYCORE_RA_SESSION_H
20
21#include <memory>
22#include "Socket.h"
23#include <boost/asio/ip/tcp.hpp>
24#include <boost/asio/streambuf.hpp>
25#include "Common.h"
26
27#include <future>
28
29using boost::asio::ip::tcp;
30
31const size_t bufferSize = 4096;
32
33class RASession : public std::enable_shared_from_this <RASession>
34{
35public:
37 {
38 }
39
40 void Start();
41
42 const std::string GetRemoteIpAddress() const { return _socket.remote_endpoint().address().to_string(); }
43 unsigned short GetRemotePort() const { return _socket.remote_endpoint().port(); }
44
45private:
46 int Send(std::string_view data);
47 std::string ReadString();
48 bool CheckAccessLevel(const std::string& user);
49 bool CheckPassword(const std::string& user, const std::string& pass);
50 bool ProcessCommand(std::string& command);
51
52 static void CommandPrint(void* callbackArg, std::string_view text);
53 static void CommandFinished(void* callbackArg, bool);
54
56 boost::asio::streambuf _readBuffer;
57 boost::asio::streambuf _writeBuffer;
58 std::promise<void>* _commandExecuting;
59};
60
61#endif
const size_t bufferSize
Definition RASession.h:31
int Send(std::string_view data)
Definition RASession.cpp:96
static void CommandFinished(void *callbackArg, bool)
std::string ReadString()
bool CheckAccessLevel(const std::string &user)
std::promise< void > * _commandExecuting
Definition RASession.h:58
boost::asio::streambuf _writeBuffer
Definition RASession.h:57
unsigned short GetRemotePort() const
Definition RASession.h:43
boost::asio::streambuf _readBuffer
Definition RASession.h:56
Trinity::Net::IoContextTcpSocket _socket
Definition RASession.h:55
bool CheckPassword(const std::string &user, const std::string &pass)
bool ProcessCommand(std::string &command)
RASession(Trinity::Net::IoContextTcpSocket &&socket)
Definition RASession.h:36
static void CommandPrint(void *callbackArg, std::string_view text)
void Start()
Definition RASession.cpp:33
const std::string GetRemoteIpAddress() const
Definition RASession.h:42
boost::asio::basic_stream_socket< boost::asio::ip::tcp, boost::asio::io_context::executor_type > IoContextTcpSocket
Definition Socket.h:41
STL namespace.