Fray Engine
Loading...
Searching...
No Matches
message_router.hpp
Go to the documentation of this file.
1
/* message_router.hpp */
2
3
#ifndef _FRAY_MESSAGE_ROUTER_HPP_
4
#define _FRAY_MESSAGE_ROUTER_HPP_
5
6
#include <optional>
7
8
#include "
log_manager.hpp
"
9
#include "
message.hpp
"
10
11
namespace
fray
12
{
13
namespace
routing
14
{
18
enum class
Destination
19
{
21
engine
,
23
relay
,
25
unsupported
26
};
27
35
inline
Destination
routeMessage
(
36
const
message::Prefix
& prefix)
37
{
38
// The engine hears every broadcast. It never relays one: every process already received it from its sender.
39
if
(prefix.
destinationKind
== PROCESS_KIND_ENGINE || prefix.
destinationKind
== PROCESS_KIND_BROADCAST)
40
return
Destination::engine
;
41
if
(prefix.
destinationKind
== PROCESS_KIND_ELECTRON_MAIN || prefix.
destinationKind
== PROCESS_KIND_ELECTRON_RENDERER)
42
return
Destination::relay
;
43
log::engineWarn
(
"Cannot route message: unsupported destination kind=%u id=%u."
,
44
static_cast<
unsigned
>
(prefix.
destinationKind
), prefix.
destinationId
);
45
return
Destination::unsupported
;
46
}
47
}
48
}
49
50
#endif
log_manager.hpp
message.hpp
fray::log::engineWarn
F_void engineWarn(const F_char *fmt,...)
Log warning for Engine.
Definition
log_manager.hpp:562
fray::routing
Definition
message_router.hpp:14
fray::routing::routeMessage
Destination routeMessage(const message::Prefix &prefix)
Decides where an incoming message goes from its prefix destination. Pure apart from logging; may run ...
Definition
message_router.hpp:35
fray::routing::Destination
Destination
Where an incoming message should be handled.
Definition
message_router.hpp:19
fray::routing::Destination::relay
@ relay
Definition
message_router.hpp:23
fray::routing::Destination::unsupported
@ unsupported
Definition
message_router.hpp:25
fray::routing::Destination::engine
@ engine
Definition
message_router.hpp:21
fray
Definition
application_state_location.hpp:28
fray::message::Prefix
Fixed-size routing prefix at the start of every frame; routers read only this. All integers are big-e...
Definition
message.hpp:53
fray::message::Prefix::destinationKind
ProcessKind destinationKind
Definition
message.hpp:57
fray::message::Prefix::destinationId
F_ulong destinationId
Definition
message.hpp:59
Engine
fray
message_router.hpp
Generated by
1.15.0