Skip to content

Commit 220c04e

Browse files
committed
Add MessageStream interface
1 parent 6bc1aa8 commit 220c04e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/interfaces/MessageStream.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
This file is part of the ArduinoIoTCloud library.
3+
4+
Copyright (c) 2024 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
11+
#pragma once
12+
13+
/******************************************************************************
14+
* INCLUDE
15+
******************************************************************************/
16+
17+
#include <message/Commands.h>
18+
#include <functional>
19+
20+
using upstreamFunction = std::function<void(Message*)>;
21+
22+
/******************************************************************************
23+
* CLASS DECLARATION
24+
******************************************************************************/
25+
26+
class MessageStream {
27+
public:
28+
MessageStream(upstreamFunction upstream): upstream(upstream) {}
29+
30+
/**
31+
* Send message upstream
32+
* @param m: message to send
33+
*/
34+
virtual inline void sendUpstream(Message* m) {
35+
upstream(m);
36+
}
37+
38+
private:
39+
upstreamFunction upstream;
40+
};

0 commit comments

Comments
 (0)