NAP
nap
system_modules
napwebsocket
src
websocketticket.h
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5
#pragma once
6
7
// External Includes
8
#include <nap/resource.h>
9
#include <rtti/deserializeresult.h>
10
11
namespace
nap
12
{
13
struct
WebSocketTicketHash;
14
20
class
NAPAPI
WebSocketTicket
:
public
Resource
21
{
22
RTTI_ENABLE(
Resource
)
23
public
:
24
// Default constructor
25
WebSocketTicket
() =
default
;
26
31
virtual
bool
init(
utility::ErrorState
& errorState)
override
;
32
39
bool
toBinaryString(std::string& outString,
utility::ErrorState
& error);
40
48
static
WebSocketTicket
* fromBinaryString(
const
std::string& binaryString,
rtti::DeserializeResult
& result,
utility::ErrorState
& error);
49
54
WebSocketTicketHash
toHash()
const
;
55
56
std::string mUsername =
""
;
57
std::string mPassword =
""
;
58
};
59
60
62
// WebSocketTicketHash
64
68
struct
NAPAPI
WebSocketTicketHash
final
69
{
70
public
:
71
WebSocketTicketHash
(
const
WebSocketTicket
& ticket);
72
73
bool
operator== (
const
WebSocketTicketHash
& rhs)
const
{
return
rhs.
mHash
== mHash; }
74
bool
operator!= (
const
WebSocketTicketHash
& rhs)
const
{
return
!(rhs == *
this
); }
75
76
std::string
mHash
;
77
};
78
}
79
80
81
// Hashes
82
namespace
std
83
{
84
template
<>
85
struct
hash<
nap
::WebSocketTicketHash>
86
{
87
size_t
operator()(
const
nap::WebSocketTicketHash
& v)
const
88
{
89
return
hash<std::string>()(v.
mHash
);
90
}
91
};
92
}
nap::WebSocketTicket
Definition:
websocketticket.h:20
nap::WebSocketTicketHash
Definition:
websocketticket.h:68
nap::utility::ErrorState
Definition:
errorstate.h:19
nap::WebSocketTicketHash::mHash
std::string mHash
Hash generated based on a ticket.
Definition:
websocketticket.h:76
nap::rtti::DeserializeResult
Definition:
deserializeresult.h:40
nap
Definition:
templateapp.h:17
nap::Resource
Definition:
resource.h:19
Generated by doxygen