Horizon Official Technical Documentation
ZoneSession.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29#ifndef HORIZON_ZONE_SESSION_ZONESESSION_HPP
30#define HORIZON_ZONE_SESSION_ZONESESSION_HPP
31
37
38#if CLIENT_TYPE == 'R'
40#elif CLIENT_TYPE == 'M'
42#elif CLIENT_TYPE == 'S'
44#elif CLIENT_TYPE == 'Z'
46#elif CLIENT_TYPE == 'A'
47#include "Server/Zone/Packets/Ad/ClientPacketLengthTable.hpp"
48#endif
49
50namespace Horizon
51{
52namespace Zone
53{
55class ZoneSocket;
62class ZoneSession : public Horizon::Networking::Session<ZoneSocket, ZoneSession>
63{
64public:
68 ZoneSession(uint64_t uid);
69
73
83 void transmit_buffer(ByteBuffer _buffer, std::size_t size);
84
89 void update(uint32_t diff);
90
93 void perform_cleanup();
94
97 void initialize();
98
101 std::unique_ptr<ZoneClientInterface> &clif() { return _clif; }
102
105 std::unique_ptr<ClientPacketLengthTable> &pkt_tbl() { return _pkt_tbl; }
106
109 std::shared_ptr<Units::Player> player() { return _player; }
110
114 void set_player(std::shared_ptr<Units::Player> pl) { _player = pl; }
115
117 std::string get_map_name() { return _map_name; }
118 void set_map_name(std::string map_name) { _map_name = map_name; }
119protected:
120 std::unique_ptr<ZoneClientInterface> _clif;
121 std::unique_ptr<ClientPacketLengthTable> _pkt_tbl;
122 std::shared_ptr<Units::Player> _player;
123 std::string _map_name{""};
124};
125}
126}
127
128#endif
Definition: ByteBuffer.hpp:78
A Session object that handles a single socket. Sockets are moved into the thread by SocketMgr,...
Definition: Session.hpp:55
Definition: ZoneSession.hpp:63
std::string _map_name
Definition: ZoneSession.hpp:123
void set_map_name(std::string map_name)
Definition: ZoneSession.hpp:118
std::string get_map_name()
Definition: ZoneSession.hpp:117
void set_player(std::shared_ptr< Units::Player > pl)
Definition: ZoneSession.hpp:114
std::unique_ptr< ZoneClientInterface > & clif()
Definition: ZoneSession.hpp:101
ZoneSession(uint64_t uid)
Definition: ZoneSession.cpp:39
std::unique_ptr< ClientPacketLengthTable > & pkt_tbl()
Definition: ZoneSession.hpp:105
void transmit_buffer(ByteBuffer _buffer, std::size_t size)
Queues a buffer to be sent to the client.
Definition: ZoneSession.cpp:76
std::shared_ptr< Units::Player > player()
Definition: ZoneSession.hpp:109
std::unique_ptr< ZoneClientInterface > _clif
Definition: ZoneSession.hpp:120
~ZoneSession()
Definition: ZoneSession.cpp:44
std::shared_ptr< Units::Player > _player
Definition: ZoneSession.hpp:122
void initialize()
Initializes the zone session's members.
Definition: ZoneSession.cpp:53
std::unique_ptr< ClientPacketLengthTable > _pkt_tbl
Definition: ZoneSession.hpp:121
void update(uint32_t diff)
Update loop for each Zone Session.
Definition: ZoneSession.cpp:110
void perform_cleanup()
Performs generic logout of player in cases where the connection was closed abruptly or by instruction...
Definition: ZoneSession.cpp:142
Definition: Element.hpp:7