-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathered_node_erlcaptureio.erl
More file actions
58 lines (48 loc) · 1.32 KB
/
ered_node_erlcaptureio.erl
File metadata and controls
58 lines (48 loc) · 1.32 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-module(ered_node_erlcaptureio).
-behaviour(ered_node).
-include("ered_nodes.hrl").
-export([
start/2,
handle_msg/2,
handle_event/2
]).
%%
%% Capture I/O messages from specific nodes and pass these on.
%%
%% This node is heavily dependent on the capture io exchange server.
%%
-import(ered_nodered_comm, [
unsupported/3
]).
-import(ered_capture_io_exchange, [
capture/3,
capture_remove/2
]).
%%
%%
start(#{<<"scope">> := <<"group">>} = NodeDef, WsName) ->
unsupported(NodeDef, {websocket, WsName}, "unsupported scope 'group'"),
ered_node:start(NodeDef, ered_node_ignore);
start(#{<<"scope">> := <<"flow">>} = NodeDef, WsName) ->
unsupported(NodeDef, {websocket, WsName}, "unsupported scope 'group'"),
ered_node:start(NodeDef, ered_node_ignore);
start(
#{<<"scope">> := NodeIds, <<"wires">> := Wires} = NodeDef, WsName
) when NodeIds =/= [], Wires =/= [[]] ->
[capture(NodeId, Wires, WsName) || NodeId <- NodeIds],
ered_node:start(NodeDef, ?MODULE);
start(NodeDef, _WsName) ->
ered_node:start(NodeDef, ?MODULE).
%%
%%
handle_event(
{stop, WsName}, #{<<"scope">> := NodeIds} = NodeDef
) when NodeIds =/= [] ->
[capture_remove(NodeId, WsName) || NodeId <- NodeIds],
NodeDef;
handle_event(_, NodeDef) ->
NodeDef.
%%
%%
handle_msg(_, NodeDef) ->
{unhandled, NodeDef}.