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
e41258ab
Commit
e41258ab
authored
Sep 04, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added group_server example to illustrate usage of publish_local_groups_at
parent
d93f6010
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
examples/group_server.cpp
examples/group_server.cpp
+62
-0
No files found.
examples/group_server.cpp
0 → 100644
View file @
e41258ab
#include <string>
#include <sstream>
#include <iostream>
#include "cppa/cppa.hpp"
using
namespace
std
;
using
namespace
cppa
;
auto
on_opt
(
char
short_opt
,
const
char
*
long_opt
)
->
decltype
(
on
(
""
,
val
<
string
>
)
||
on
(
function
<
option
<
string
>
(
const
string
&
)
>
()))
{
const
char
short_flag_arr
[]
=
{
'-'
,
short_opt
,
'\0'
};
const
char
*
lhs_str
=
short_flag_arr
;
string
prefix
=
"--"
;
prefix
+=
long_opt
;
prefix
+=
"="
;
function
<
option
<
string
>
(
const
string
&
)
>
kvp
=
[
prefix
](
const
string
&
input
)
->
option
<
string
>
{
if
(
input
.
compare
(
0
,
prefix
.
size
(),
prefix
)
==
0
// accept '-key=' as well
||
input
.
compare
(
1
,
prefix
.
size
(),
prefix
)
==
0
)
{
return
input
.
substr
(
prefix
.
size
());
}
return
{};
};
return
on
(
lhs_str
,
val
<
string
>
)
||
on
(
kvp
);
}
auto
on_void_opt
(
char
short_opt
,
const
char
*
long_opt
)
->
decltype
(
on
<
string
>
().
when
(
cppa
::
placeholders
::
_x1
.
in
(
vector
<
string
>
())))
{
const
char
short_flag_arr
[]
=
{
'-'
,
short_opt
,
'\0'
};
vector
<
string
>
opt_strs
=
{
short_flag_arr
};
opt_strs
.
push_back
(
string
(
"-"
)
+
long_opt
);
string
str
=
"-"
;
str
+=
opt_strs
.
back
();
opt_strs
.
push_back
(
std
::
move
(
str
));
return
on
<
string
>
().
when
(
cppa
::
placeholders
::
_x1
.
in
(
opt_strs
));
}
int
main
(
int
argc
,
char
**
argv
)
{
uint16_t
port
;
bool
args_valid
=
argc
>
1
&&
match_stream
<
string
>
(
argv
+
1
,
argv
+
argc
)
(
on_opt
(
'p'
,
"port"
)
>>
[
&
](
const
string
&
arg
)
->
bool
{
if
(
!
(
istringstream
(
arg
)
>>
port
))
{
cout
<<
"
\"
"
<<
arg
<<
"
\"
is not a valid port"
<<
endl
;
return
false
;
}
return
true
;
}
);
if
(
!
args_valid
)
return
1
;
if
(
port
<=
1024
)
{
cout
<<
"no port > 1024 given"
<<
endl
;
return
2
;
}
publish_local_groups_at
(
port
);
cout
<<
"type 'quit' to shutdown the server"
<<
endl
;
string
line
;
while
(
getline
(
cin
,
line
))
{
if
(
line
==
"quit"
)
return
0
;
else
{
cout
<<
"illegal command"
<<
endl
;
}
}
return
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