Encapsulate a chat event.
More...
#include <SimpleChatServer.h>
|
Type | type () const |
| Get the event type. More...
|
|
const Wt::WString & | user () const |
| Get the user who caused the event. More...
|
|
const Wt::WString & | message () const |
| Get the message of the event. More...
|
|
const Wt::WString & | data () const |
| Get the extra data for this event. More...
|
|
const Wt::WString | formattedHTML (const Wt::WString &user, Wt::TextFormat format) const |
| Get the message formatted as HTML, rendered for the given user. More...
|
|
Encapsulate a chat event.
Definition at line 29 of file SimpleChatServer.h.
§ Type
Enumeration for the event type.
Enumerator |
---|
Login | |
Logout | |
Rename | |
Message | |
Definition at line 34 of file SimpleChatServer.h.
§ ChatEvent() [1/2]
ChatEvent::ChatEvent |
( |
const Wt::WString & |
user, |
|
|
const Wt::WString & |
message |
|
) |
| |
|
inlineprivate |
Definition at line 68 of file SimpleChatServer.h.
const Wt::WString & message() const
Get the message of the event.
const Wt::WString & user() const
Get the user who caused the event.
§ ChatEvent() [2/2]
ChatEvent::ChatEvent |
( |
Type |
type, |
|
|
const Wt::WString & |
user, |
|
|
const Wt::WString & |
data = Wt::WString::Empty |
|
) |
| |
|
inlineprivate |
Definition at line 72 of file SimpleChatServer.h.
Type type() const
Get the event type.
const Wt::WString & data() const
Get the extra data for this event.
const Wt::WString & user() const
Get the user who caused the event.
§ data()
const Wt::WString& ChatEvent::data |
( |
| ) |
const |
|
inline |
§ formattedHTML()
const Wt::WString ChatEvent::formattedHTML |
( |
const Wt::WString & |
user, |
|
|
Wt::TextFormat |
format |
|
) |
| const |
Get the message formatted as HTML, rendered for the given user.
The format
indicates how the message should be formatted.
Definition at line 13 of file SimpleChatServer.C.
18 return Wt::WString(
"<span class='chat-info'>")
19 + Wt::WWebWidget::escapeText(
user_) +
" joined.</span>";
21 return Wt::WString(
"<span class='chat-info'>")
24 Wt::WWebWidget::escapeText(
user_))
25 +
" logged out.</span>";
27 return "<span class='chat-info'>" 30 (Wt::WWebWidget::escapeText(
user_) +
" is"))
31 +
" now known as " + Wt::WWebWidget::escapeText(
data_) +
".</span>";
35 result = Wt::WString(
"<span class='")
39 +
"'>" + Wt::WWebWidget::escapeText(
user_) +
":</span>";
42 = (format == Wt::TextFormat::XHTML ?
message_ : Wt::WWebWidget::escapeText(
message_));
44 if (
message_.toUTF8().find(
user.toUTF8()) != std::string::npos)
45 return result +
"<span class='chat-highlight'>" + msg +
"</span>";
const Wt::WString & user() const
Get the user who caused the event.
§ message()
const Wt::WString& ChatEvent::message |
( |
| ) |
const |
|
inline |
§ type()
Type ChatEvent::type |
( |
| ) |
const |
|
inline |
§ user()
const Wt::WString& ChatEvent::user |
( |
| ) |
const |
|
inline |
§ SimpleChatServer
§ data_
Wt::WString ChatEvent::data_ |
|
private |
§ message_
Wt::WString ChatEvent::message_ |
|
private |
§ type_
§ user_
Wt::WString ChatEvent::user_ |
|
private |
The documentation for this class was generated from the following files: