Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
362c5b5e
Commit
362c5b5e
authored
Feb 04, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add interface to get a remote actor's IP and port
Close #419
parent
86ab5ae8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
4 deletions
+38
-4
libcaf_io/caf/io/middleman_actor.hpp
libcaf_io/caf/io/middleman_actor.hpp
+3
-1
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+11
-0
libcaf_io/src/middleman_actor.cpp
libcaf_io/src/middleman_actor.cpp
+6
-0
libcaf_io/src/test_multiplexer.cpp
libcaf_io/src/test_multiplexer.cpp
+3
-3
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+15
-0
No files found.
libcaf_io/caf/io/middleman_actor.hpp
View file @
362c5b5e
...
@@ -109,7 +109,9 @@ using middleman_actor =
...
@@ -109,7 +109,9 @@ using middleman_actor =
reacts_to
<
close_atom
,
uint16_t
>
,
reacts_to
<
close_atom
,
uint16_t
>
,
replies_to
<
spawn_atom
,
node_id
,
std
::
string
,
message
>
replies_to
<
spawn_atom
,
node_id
,
std
::
string
,
message
>
::
with
<
ok_atom
,
actor_addr
,
std
::
set
<
std
::
string
>>>
;
::
with
<
ok_atom
,
actor_addr
,
std
::
set
<
std
::
string
>>
,
replies_to
<
get_atom
,
node_id
>::
with
<
node_id
,
std
::
string
,
uint16_t
>>
;
/// @relates middleman_actor
/// @relates middleman_actor
middleman_actor
make_middleman_actor
(
actor_system
&
sys
,
actor
default_broker
);
middleman_actor
make_middleman_actor
(
actor_system
&
sys
,
actor
default_broker
);
...
...
libcaf_io/src/basp_broker.cpp
View file @
362c5b5e
...
@@ -659,6 +659,17 @@ behavior basp_broker::make_behavior() {
...
@@ -659,6 +659,17 @@ behavior basp_broker::make_behavior() {
});
});
}
}
},
},
[
=
](
get_atom
,
const
node_id
&
x
)
->
std
::
tuple
<
node_id
,
std
::
string
,
uint16_t
>
{
std
::
string
addr
;
uint16_t
port
=
0
;
auto
hdl
=
state
.
instance
.
tbl
().
lookup_direct
(
x
);
if
(
hdl
!=
invalid_connection_handle
)
{
addr
=
remote_addr
(
hdl
);
port
=
remote_port
(
hdl
);
}
return
std
::
make_tuple
(
x
,
std
::
move
(
addr
),
port
);
},
// catch-all error handler
// catch-all error handler
others
>>
[
=
]
{
others
>>
[
=
]
{
CAF_LOG_ERROR
(
"unexpected message:"
<<
CAF_ARG
(
current_message
()));
CAF_LOG_ERROR
(
"unexpected message:"
<<
CAF_ARG
(
current_message
()));
...
...
libcaf_io/src/middleman_actor.cpp
View file @
362c5b5e
...
@@ -152,6 +152,12 @@ public:
...
@@ -152,6 +152,12 @@ public:
forward_current_message
(
broker_
);
forward_current_message
(
broker_
);
return
{};
return
{};
},
},
[
=
](
get_atom
,
const
node_id
&
)
->
delegated
<
node_id
,
std
::
string
,
uint16_t
>
{
CAF_LOG_TRACE
(
""
);
forward_current_message
(
broker_
);
return
{};
},
[
=
](
const
down_msg
&
dm
)
{
[
=
](
const
down_msg
&
dm
)
{
auto
i
=
cached_
.
begin
();
auto
i
=
cached_
.
begin
();
auto
e
=
cached_
.
end
();
auto
e
=
cached_
.
end
();
...
...
libcaf_io/src/test_multiplexer.cpp
View file @
362c5b5e
...
@@ -79,11 +79,11 @@ void test_multiplexer::assign_tcp_scribe(abstract_broker* ptr,
...
@@ -79,11 +79,11 @@ void test_multiplexer::assign_tcp_scribe(abstract_broker* ptr,
}
}
std
::
string
addr
()
const
override
{
std
::
string
addr
()
const
override
{
return
std
::
string
{}
;
return
"test"
;
}
}
uint16_t
port
()
const
override
{
uint16_t
port
()
const
override
{
return
0
;
return
static_cast
<
uint16_t
>
(
hdl
().
id
())
;
}
}
private:
private:
...
@@ -150,7 +150,7 @@ void test_multiplexer::assign_tcp_doorman(abstract_broker* ptr,
...
@@ -150,7 +150,7 @@ void test_multiplexer::assign_tcp_doorman(abstract_broker* ptr,
}
}
std
::
string
addr
()
const
override
{
std
::
string
addr
()
const
override
{
return
std
::
string
{}
;
return
"test"
;
}
}
uint16_t
port
()
const
override
{
uint16_t
port
()
const
override
{
...
...
libcaf_io/test/basp.cpp
View file @
362c5b5e
...
@@ -472,6 +472,21 @@ CAF_TEST(non_empty_server_handshake) {
...
@@ -472,6 +472,21 @@ CAF_TEST(non_empty_server_handshake) {
CAF_CHECK
(
hexstr
(
buf
)
==
hexstr
(
expected_buf
));
CAF_CHECK
(
hexstr
(
buf
)
==
hexstr
(
expected_buf
));
}
}
CAF_TEST
(
remote_address_and_port
)
{
connect_node
(
1
);
auto
mm
=
system
.
middleman
().
actor_handle
();
self
()
->
send
(
mm
,
get_atom
::
value
,
remote_node
(
1
));
mpx
()
->
exec_runnable
();
self
()
->
receive
(
[
&
](
const
node_id
&
nid
,
const
std
::
string
&
addr
,
uint16_t
port
)
{
CAF_CHECK
(
nid
==
remote_node
(
1
));
// all test nodes have address "test" and connection handle ID as port
CAF_CHECK
(
addr
==
"test"
);
CAF_CHECK
(
port
==
remote_hdl
(
1
).
id
());
}
);
}
CAF_TEST
(
client_handshake_and_dispatch
)
{
CAF_TEST
(
client_handshake_and_dispatch
)
{
connect_node
(
0
);
connect_node
(
0
);
// send a message via `dispatch` from node 0
// send a message via `dispatch` from node 0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment