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
88b984d8
Commit
88b984d8
authored
Nov 27, 2020
by
Hauke Goldhammer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broadcast every client input
parent
41cd6259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
examples/qtsupport/chatwidget.cpp
examples/qtsupport/chatwidget.cpp
+25
-24
No files found.
examples/qtsupport/chatwidget.cpp
View file @
88b984d8
...
@@ -71,38 +71,39 @@ void ChatWidget::sendChatMessage() {
...
@@ -71,38 +71,39 @@ void ChatWidget::sendChatMessage() {
input
()
->
setText
(
QString
());
input
()
->
setText
(
QString
());
});
});
QString
line
=
input
()
->
text
();
QString
line
=
input
()
->
text
();
if
(
line
.
startsWith
(
'/'
))
{
if
(
line
.
isEmpty
())
{
// Ignore empty lines.
}
else
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
(
" "
));
if
(
words
.
size
()
>
1
)
{
if
(
words
.
size
()
==
3
&&
words
[
0
]
==
"join"
)
{
if
(
words
[
0
]
==
"join"
&&
words
.
size
()
==
3
)
{
if
(
auto
x
=
system
().
groups
().
get
(
words
[
1
],
words
[
2
]))
if
(
auto
x
=
system
().
groups
().
get
(
words
[
1
],
words
[
2
]))
send_as
(
as_actor
(),
as_actor
(),
join_atom_v
,
std
::
move
(
*
x
));
self
()
->
send
(
self
(),
join_atom_v
,
std
::
move
(
*
x
));
else
else
print
(
"*** error: "
+
QString
::
fromUtf8
(
to_string
(
x
.
error
()).
c_str
()));
print
(
"*** error: "
}
else
if
(
words
.
size
()
==
2
&&
words
[
0
]
==
"setName"
)
+
QString
::
fromUtf8
(
to_string
(
x
.
error
()).
c_str
()));
send_as
(
as_actor
(),
as_actor
(),
set_name_atom_v
,
std
::
move
(
words
[
1
]));
}
else
if
(
words
[
0
]
==
"setName"
&&
words
.
size
()
==
2
)
else
{
send_as
(
as_actor
(),
as_actor
(),
set_name_atom_v
,
std
::
move
(
words
[
1
]));
}
else
{
print
(
"*** list of commands:
\n
"
print
(
"*** list of commands:
\n
"
"/join <module> <group id>
\n
"
"/join <module> <group id>
\n
"
"/setName <new name>
\n
"
);
"/setName <new name>
\n
"
);
return
;
return
;
}
}
}
else
{
if
(
name_
.
empty
())
{
print
(
"*** please set a name before sending messages"
);
return
;
}
if
(
!
chatroom_
)
{
print
(
"*** no one is listening... please join a group"
);
return
;
}
string
msg
=
name_
;
msg
+=
": "
;
msg
+=
line
.
toUtf8
().
constData
();
print
(
"<you>: "
+
input
()
->
text
());
send_as
(
as_actor
(),
chatroom_
,
std
::
move
(
msg
));
}
}
if
(
name_
.
empty
())
{
print
(
"*** please set a name before sending messages"
);
return
;
}
if
(
!
chatroom_
)
{
print
(
"*** no one is listening... please join a group"
);
return
;
}
string
msg
=
name_
;
msg
+=
": "
;
msg
+=
line
.
toUtf8
().
constData
();
print
(
"<you>: "
+
input
()
->
text
());
send_as
(
as_actor
(),
chatroom_
,
std
::
move
(
msg
));
}
}
void
ChatWidget
::
joinGroup
()
{
void
ChatWidget
::
joinGroup
()
{
...
...
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