Loading...
Searching...
No Matches
websocket_handler.h
1/*
2* Nebula Atom
3
4* This program is free software: you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation, either version 3 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef NAF_HANDLERS_WEBSOCKETHANDLER
19#define NAF_HANDLERS_WEBSOCKETHANDLER
20
21
22#include "Poco/Net/WebSocket.h"
23#include "Poco/Net/NetException.h"
24
25#include "handlers/root_handler.h"
26#include "http/request.h"
27
28
29namespace NAF
30{
31 namespace Handlers
32 {
33 class WebSocketHandler;
34 }
35}
36
37
39 public RootHandler
40{
41 public:
42 using VectorSocket = std::vector<const WebSocketHandler*>;
43
45 virtual ~WebSocketHandler();
46
47 void Send_(std::string message) const;
48
49 protected:
50 virtual void Process_() override;
51 void Transfer_();
52 virtual void HandleNewConnection_(HTTP::Request& request, const WebSocketHandler& websocket_handler) = 0;
53 virtual void HandleNewMessage_(const WebSocketHandler& websocket_handler, std::string message) = 0;
54 virtual void HandleConnectionClosed_(const WebSocketHandler& websocket_handler) = 0;
55
56 private:
57 std::unique_ptr<WebSocket> websocket_;
58};
59
60#endif // NAF_HANDLERS_WEBSOCKETHANDLER
Definition request.h:80
Definition root_handler.h:98
Definition websocket_handler.h:40