Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Server.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_SERVER_H_
34#define DVD_SERVER_H_
35
37
38//----------------------------------------------------------------------
39namespace Divide {
40
43
44class Server {
45 public:
46 Server();
47 ~Server();
48
49 void init(U16 port,
50 const string& broadcast_endpoint_address,
51 bool debugOutput);
52
53 void close();
54
55 private:
56 void handle_accept(const tcp_session_tpl_ptr& session, const boost::system::error_code& ec);
57
58 private:
59 boost::asio::io_context _ioService;
60 std::unique_ptr<std::thread> _thread;
61 std::unique_ptr<tcp_acceptor> _acceptor;
62 channel_ptr _channel;
63 bool _debugOutput{false};
64
65};
66
67}; // namespace Divide
68
69#endif //DVD_SERVER_H_
#define FWD_DECLARE_MANAGED_CLASS(T)
std::unique_ptr< std::thread > _thread
Definition: Server.h:60
void close()
Definition: Server.cpp:23
void handle_accept(const tcp_session_tpl_ptr &session, const boost::system::error_code &ec)
Definition: Server.cpp:75
void init(U16 port, const string &broadcast_endpoint_address, bool debugOutput)
Definition: Server.cpp:36
std::unique_ptr< tcp_acceptor > _acceptor
Definition: Server.h:61
channel_ptr _channel
Definition: Server.h:62
bool _debugOutput
Definition: Server.h:63
boost::asio::io_context _ioService
Definition: Server.h:59
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint16_t U16