-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebSocketMessage
More file actions
44 lines (34 loc) · 905 Bytes
/
WebSocketMessage
File metadata and controls
44 lines (34 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (C) 2025 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#pragma once
#include <cc/WebSocketFrame>
namespace cc {
/** WebSocket message
*/
class WebSocketMessage: public Object
{
public:
using Type = WebSocketFrame::Type;
WebSocketMessage(Type type, const String &payload):
Object{new State{type, payload}}
{}
Type type() const { return me().type_; }
String payload() const { return me().payload_; }
protected:
struct State final: public Object::State
{
State(Type type, const String &payload):
type_{type},
payload_{payload}
{}
Type type_ { Type::Continuation };
String payload_;
};
const State &me() const { return Object::me.as<State>(); }
};
} // namespace cc