10 #include <Wt/WApplication>
11 #include <Wt/WContainerWidget>
12 #include <Wt/WEnvironment>
13 #include <Wt/WHBoxLayout>
14 #include <Wt/WVBoxLayout>
16 #include <Wt/WLineEdit>
18 #include <Wt/WTextArea>
19 #include <Wt/WPushButton>
20 #include <Wt/WCheckBox>
93 statusMsg_->setText(
"Sorry, name '" + escapeText(name) +
94 "' is already taken.");
174 if (flags & RenderFull) {
180 +
messages_->jsRef() +
".scrollHeight;}, 0);");
184 WContainerWidget::render(flags);
209 messages_->setOverflow(WContainerWidget::OverflowAuto);
210 userList_->setOverflow(WContainerWidget::OverflowAuto);
230 (
"function(o, e) { setTimeout(function() {"
249 (
"<div><span class='chat-info'>You are joining as "
250 + escapeText(
user_) +
".</span></div>",
264 if (!logoutButton->parent())
290 for (SimpleChatServer::UserSet::iterator i = users.begin();
291 i != users.end(); ++i) {
295 UserMap::const_iterator j = oldUsers.find(*i);
296 if (j != oldUsers.end())
385 +
messages_->jsRef() +
".scrollHeight;");
void addLayout(WLayout *layout, int stretch=0, WFlags< AlignmentFlag > alignment=0)
void sendMessage(const Wt::WString &user, const Wt::WString &message)
Send a message on behalve of a user.
bool connect(Client *client, const ChatEventCallback &handleEvent)
Connects to the chat server.
Encapsulate a chat event.
const Wt::WString formattedHTML(const Wt::WString &user, Wt::TextFormat format) const
Get the message formatted as HTML, rendered for the given user.
UserSet users()
Get the users currently logged in.
std::set< Wt::WString > UserSet
Typedef for a collection of user names.
Wt::WString suggestGuest()
Get a suggestion for a guest user name.
bool login(const Wt::WString &user)
Try to login with given user name.
bool disconnect(Client *client)
Disconnect from the chat server.
void enableUpdates(bool enabled=true)
virtual void setText(const WString &text)
void logout(const Wt::WString &user)
Logout from the server.
const WString & text() const
static WApplication * instance()
void setResizable(int index, bool enabled=true, const WLength &initialSize=WLength::Auto)
void setJavaScript(const std::string &javaScript)
const Wt::WString & user() const
Get the user who caused the event.
void addWidget(WWidget *widget, int stretch=0, WFlags< AlignmentFlag > alignment=0)
Type type() const
Get the event type.
void doJavaScript(const std::string &javascript, bool afterLoaded=true)
const Wt::WString & data() const
Get the extra data for this event.