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 "Define.h"
22#include "Socket.h"
23#include <boost/asio/ip/tcp.hpp>
24#include <boost/asio/streambuf.hpp>
25#include <future>
26#include <memory>
27
28const size_t bufferSize = 4096;
29
30class RASession : public std::enable_shared_from_this <RASession>
31{
32public:
34 {
35 }
36
37 void Start();
38
39 boost::asio::ip::address GetRemoteIpAddress() const { return _socket.remote_endpoint().address(); }
40 uint16 GetRemotePort() const { return _socket.remote_endpoint().port(); }
41
42private:
43 int Send(std::string_view data);
44 std::string ReadString();
45 bool CheckAccessLevel(const std::string& user);
46 bool ProcessCommand(std::string& command);
47
48 static void CommandPrint(void* callbackArg, std::string_view text);
49 static void CommandFinished(void* callbackArg, bool);
50
52 boost::asio::streambuf _readBuffer;
53 boost::asio::streambuf _writeBuffer;
54 std::promise<void>* _commandExecuting;
55};
56
57#endif
uint16_t uint16
Definition Define.h:155
const size_t bufferSize
Definition RASession.h:28
int Send(std::string_view data)
Definition RASession.cpp:94
static void CommandFinished(void *callbackArg, bool)
std::string ReadString()
bool CheckAccessLevel(const std::string &user)
std::promise< void > * _commandExecuting
Definition RASession.h:54
boost::asio::streambuf _writeBuffer
Definition RASession.h:53
boost::asio::streambuf _readBuffer
Definition RASession.h:52
uint16 GetRemotePort() const
Definition RASession.h:40
Trinity::Net::IoContextTcpSocket _socket
Definition RASession.h:51
bool ProcessCommand(std::string &command)
RASession(Trinity::Net::IoContextTcpSocket &&socket)
Definition RASession.h:33
static void CommandPrint(void *callbackArg, std::string_view text)
boost::asio::ip::address GetRemoteIpAddress() const
Definition RASession.h:39
void Start()
Definition RASession.cpp:31
boost::asio::basic_stream_socket< boost::asio::ip::tcp, boost::asio::io_context::executor_type > IoContextTcpSocket
Definition Socket.h:40
STL namespace.