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
3d6e6a88
Commit
3d6e6a88
authored
Nov 09, 2020
by
Hauke Goldhammer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove message builder
parent
c3ebd01f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
34 deletions
+29
-34
examples/qtsupport/chatwidget.cpp
examples/qtsupport/chatwidget.cpp
+15
-24
examples/qtsupport/qt_group_chat.cpp
examples/qtsupport/qt_group_chat.cpp
+14
-10
No files found.
examples/qtsupport/chatwidget.cpp
View file @
3d6e6a88
...
@@ -68,31 +68,22 @@ void ChatWidget::sendChatMessage() {
...
@@ -68,31 +68,22 @@ void ChatWidget::sendChatMessage() {
if
(
line
.
startsWith
(
'/'
))
{
if
(
line
.
startsWith
(
'/'
))
{
vector
<
string
>
words
;
vector
<
string
>
words
;
split
(
words
,
line
.
midRef
(
1
).
toUtf8
().
constData
(),
is_any_of
(
" "
));
split
(
words
,
line
.
midRef
(
1
).
toUtf8
().
constData
(),
is_any_of
(
" "
));
message_builder
mb
;
if
(
words
.
size
()
>
1
)
if
(
words
.
size
()
>
1
)
{
if
(
words
.
front
()
==
"join"
&&
words
.
size
()
==
3
)
{
// convert first word to an atom
auto
x
=
system
().
groups
().
get
(
words
[
1
],
words
[
2
]);
mb
.
append
(
atom_from_string
(
words
.
front
()))
if
(
!
x
)
.
append
(
words
.
begin
()
+
1
,
words
.
end
());
print
(
"*** error: "
};
+
QString
::
fromUtf8
(
to_string
(
x
.
error
()).
c_str
()));
auto
res
=
mb
.
apply
({
else
[
=
](
join_atom
,
const
string
&
mod
,
const
string
&
g
)
{
self
()
->
send
(
self
(),
join_atom_v
,
std
::
move
(
*
x
));
auto
x
=
system
().
groups
().
get
(
mod
,
g
);
}
else
if
(
words
.
front
()
==
"setName"
&&
words
.
size
()
==
2
)
if
(
!
x
)
send_as
(
as_actor
(),
as_actor
(),
set_name_atom_v
,
std
::
move
(
words
[
1
]));
print
(
"*** error: "
}
else
{
+
QString
::
fromUtf8
(
to_string
(
x
.
error
()).
c_str
()));
print
(
"*** list of commands:
\n
"
else
"/join <module> <group id>
\n
"
self
()
->
send
(
self
(),
join_atom_v
,
std
::
move
(
*
x
));
"/setName <new name>
\n
"
);
},
return
;
[
=
](
set_name_atom
,
string
&
name
)
{
send_as
(
as_actor
(),
as_actor
(),
set_name_atom_v
,
std
::
move
(
name
));
}
}
});
if
(
!
res
)
print
(
"*** list of commands:
\n
"
"/join <module> <group id>
\n
"
"/setName <new name>
\n
"
);
return
;
}
if
(
name_
.
empty
())
{
if
(
name_
.
empty
())
{
print
(
"*** please set a name before sending messages"
);
print
(
"*** please set a name before sending messages"
);
return
;
return
;
...
...
examples/qtsupport/qt_group_chat.cpp
View file @
3d6e6a88
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
* terminal version in remote_actors/group_chat.cpp. *
* terminal version in remote_actors/group_chat.cpp. *
* *
* *
* Setup for a minimal chat between "alice" and "bob": *
* Setup for a minimal chat between "alice" and "bob": *
* - ./build/
bin/group_server -p 4242
*
* - ./build/
examples/group_server -p 4242
*
* - ./build/
bin/qt_group_chat -g remote:chatroom@localhost:4242 -n alice
*
* - ./build/
examples/qt_group_chat -g remote:chatroom@localhost:4242 -n alice
*
* - ./build/
bin/qt_group_chat -g remote:chatroom@localhost:4242 -n bob
*
* - ./build/
examples/qt_group_chat -g remote:chatroom@localhost:4242 -n bob
*
\******************************************************************************/
\******************************************************************************/
#include <set>
#include <set>
...
@@ -36,18 +36,22 @@ public:
...
@@ -36,18 +36,22 @@ public:
std
::
string
name
;
std
::
string
name
;
std
::
string
group_id
;
std
::
string
group_id
;
config
(
int
argc
,
char
**
argv
)
{
config
()
{
opt_group
{
custom_options_
,
"global"
}
opt_group
{
custom_options_
,
"global"
}
.
add
(
name
,
"name,n"
,
"set name"
)
.
add
(
name
,
"name,n"
,
"set name"
)
.
add
(
group_id
,
"group,g"
,
"join group (format: <module>:<id>"
);
.
add
(
group_id
,
"group,g"
,
"join group (format: <module>:<id>)"
);
parse
(
argc
,
argv
);
load
<
io
::
middleman
>
();
io
::
middleman
::
init_global_meta_objects
();
}
}
};
};
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
config
cfg
{
argc
,
argv
};
init_global_meta_objects
<
id_block
::
qt_support
>
();
core
::
init_global_meta_objects
();
io
::
middleman
::
init_global_meta_objects
();
config
cfg
{};
auto
err
=
cfg
.
parse
(
argc
,
argv
);
if
(
cfg
.
cli_helptext_printed
)
return
0
;
cfg
.
load
<
io
::
middleman
>
();
actor_system
system
{
cfg
};
actor_system
system
{
cfg
};
auto
name
=
cfg
.
name
;
auto
name
=
cfg
.
name
;
group
grp
;
group
grp
;
...
...
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