Debian Codegraph @

doc/src/manual/cowboy_stream.info.asciidoc

raw
1 = cowboy_stream:info(3)
2
3 == Name
4
5 cowboy_stream:info - Handle a message for a stream
6
7 == Description
8
9 [source,erlang]
10 ----
11 info(StreamID, Info, State) -> {Commands, State}
12
13 StreamID :: cowboy_stream:stream_id()
14 Info :: any()
15 Commands :: cowboy_stream:commands()
16 State - opaque
17 ----
18
19 Handle a message for a stream.
20
21 This function should be called by all stream handlers. It will
22 propagate the event to the next configured stream handler.
23 Handlers do not have to propagate events that have been
24 fully handled.
25
26 == Arguments
27
28 StreamID::
29
30 The stream ID.
31
32 Info::
33
34 The event received.
35
36 Commands::
37
38 The commands to be executed.
39
40 State::
41
42 The state for the next stream handler.
43
44 == Return value
45
46 A list of commands and an opaque state is returned.
47
48 The list of commands returned should be included in the
49 commands returned from the current stream handler. It
50 can be modified if necessary.
51
52 The state should be stored in the current stream
53 handler's state and passed to `cowboy_stream` when
54 necessary. The state should be treated as opaque.
55
56 == Changelog
57
58 * *2.0*: Function introduced.
59
60 == Examples
61
62 .Propagate an event to the next stream handler
63 [source,erlang]
64 ----
65 info(StreamID, Info, State=#state{next=Next0}) ->
66 MyCommands = my_commands(),
67 {Commands, Next} = cowboy_stream:info(StreamID, Info, Next0),
68 {MyCommands ++ Commands, #state{next=Next}}.
69 ----
70
71 == See also
72
73 link:man:cowboy_stream(3)[cowboy_stream(3)],
74 link:man:cowboy_stream:init(3)[cowboy_stream:init(3)],
75 link:man:cowboy_stream:data(3)[cowboy_stream:data(3)],
76 link:man:cowboy_stream:terminate(3)[cowboy_stream:terminate(3)],
77 link:man:cowboy_stream:early_error(3)[cowboy_stream:early_error(3)]