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
6d7c2053
Commit
6d7c2053
authored
Jun 29, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use dynamic port in UDP test case
parent
36fb5045
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
libcaf_io/test/remote_actor_udp.cpp
libcaf_io/test/remote_actor_udp.cpp
+12
-10
No files found.
libcaf_io/test/remote_actor_udp.cpp
View file @
6d7c2053
...
@@ -196,7 +196,7 @@ CAF_TEST(remote_link_udp) {
...
@@ -196,7 +196,7 @@ CAF_TEST(remote_link_udp) {
CAF_TEST
(
multiple_endpoints_udp
)
{
CAF_TEST
(
multiple_endpoints_udp
)
{
config
cfg
;
config
cfg
;
//
setup server
//
Setup server.
CAF_MESSAGE
(
"creating server"
);
CAF_MESSAGE
(
"creating server"
);
actor_system
server_sys
{
cfg
};
actor_system
server_sys
{
cfg
};
auto
mirror
=
server_sys
.
spawn
([]()
->
behavior
{
auto
mirror
=
server_sys
.
spawn
([]()
->
behavior
{
...
@@ -207,7 +207,9 @@ CAF_TEST(multiple_endpoints_udp) {
...
@@ -207,7 +207,9 @@ CAF_TEST(multiple_endpoints_udp) {
}
}
};
};
});
});
server_sys
.
middleman
().
publish_udp
(
mirror
,
12345
);
auto
port
=
server_sys
.
middleman
().
publish_udp
(
mirror
,
0
);
CAF_REQUIRE
(
port
);
CAF_MESSAGE
(
"server running on port "
<<
port
);
auto
client_fun
=
[](
event_based_actor
*
self
)
->
behavior
{
auto
client_fun
=
[](
event_based_actor
*
self
)
->
behavior
{
return
{
return
{
[
=
](
actor
s
)
{
[
=
](
actor
s
)
{
...
@@ -220,29 +222,29 @@ CAF_TEST(multiple_endpoints_udp) {
...
@@ -220,29 +222,29 @@ CAF_TEST(multiple_endpoints_udp) {
}
}
};
};
};
};
//
setup client a
//
Setup a client.
CAF_MESSAGE
(
"creating first client"
);
CAF_MESSAGE
(
"creating first client"
);
config
client_cfg
;
config
client_cfg
;
actor_system
client_sys
{
client_cfg
};
actor_system
client_sys
{
client_cfg
};
auto
client
=
client_sys
.
spawn
(
client_fun
);
auto
client
=
client_sys
.
spawn
(
client_fun
);
//
acquire remote actor from the server
//
Acquire remote actor from the server.
auto
client_srv
=
client_sys
.
middleman
().
remote_actor_udp
(
"localhost"
,
12345
);
auto
client_srv
=
client_sys
.
middleman
().
remote_actor_udp
(
"localhost"
,
*
port
);
CAF_REQUIRE
(
client_srv
);
CAF_REQUIRE
(
client_srv
);
//
setup other clients
//
Setup other clients.
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
config
other_cfg
;
config
other_cfg
;
actor_system
other_sys
{
other_cfg
};
actor_system
other_sys
{
other_cfg
};
CAF_MESSAGE
(
"creating new client"
);
CAF_MESSAGE
(
"creating new client"
);
auto
other
=
other_sys
.
spawn
(
client_fun
);
auto
other
=
other_sys
.
spawn
(
client_fun
);
//
acquire remote actor from the server
//
Acquire remote actor from the new server.
auto
other_srv
=
other_sys
.
middleman
().
remote_actor_udp
(
"localhost"
,
12345
);
auto
other_srv
=
other_sys
.
middleman
().
remote_actor_udp
(
"localhost"
,
*
port
);
CAF_REQUIRE
(
other_srv
);
CAF_REQUIRE
(
other_srv
);
//
establish communication and exit
//
Establish communication and exit.
CAF_MESSAGE
(
"client contacts server and exits"
);
CAF_MESSAGE
(
"client contacts server and exits"
);
anon_send
(
other
,
*
other_srv
);
anon_send
(
other
,
*
other_srv
);
other_sys
.
await_all_actors_done
();
other_sys
.
await_all_actors_done
();
}
}
//
establish communication and exit
//
Start communicate from the first actor.
CAF_MESSAGE
(
"first client contacts server and exits"
);
CAF_MESSAGE
(
"first client contacts server and exits"
);
anon_send
(
client
,
*
client_srv
);
anon_send
(
client
,
*
client_srv
);
client_sys
.
await_all_actors_done
();
client_sys
.
await_all_actors_done
();
...
...
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