7#include <Wt/WApplication.h>
8#include <Wt/WContainerWidget.h>
9#include <Wt/WEnvironment.h>
10#include <Wt/WPushButton.h>
11#include <Wt/WServer.h>
35 const Wt::WEnvironment&
env_;
58 root()->addWidget(std::make_unique<Wt::WText>(Wt::WString::tr(
"introduction")));
61 root()->addWidget(std::make_unique<SimpleChatWidget>(
server_));
64 root()->addWidget(std::make_unique<Wt::WText>(Wt::WString::tr(
"details")));
67 root()->addWidget(std::make_unique<Wt::WPushButton>(
"I'm schizophrenic ..."));
68 b->clicked().
connect(
b, &Wt::WPushButton::hide);
74 if(!
env_.javaScript()){
76 root()->addWidget(std::make_unique<Wt::WText>(Wt::WString::tr(
"serverpushwarning")));
80 timer_ = std::make_unique<Wt::WTimer>();
81 timer_->setInterval(std::chrono::milliseconds{5000});
93 root()->addWidget(std::make_unique<SimpleChatWidget>(
server_));
109 :
Wt::WApplication(
env),
110 login_(
this,
"login")
118 const std::string *
div =
env.getParameter(
"div");
126 std::make_unique<PopupChatWidget>(server, *
div);
134 +
chat +
".emit(" +
chat +
", 'login', " +
chat +
"User);"
135 +
"document.body.appendChild(" +
chatWidget->jsRef() +
");");
137 std::cerr <<
"Missing: parameter: 'div'" << std::endl;
145 return std::make_unique<ChatApplication>(
env, server);
150 return std::make_unique<ChatWidget>(
env, server);
162 server.addEntryPoint(Wt::EntryPointType::Application,
165 server.addEntryPoint(Wt::EntryPointType::WidgetSet,
169 if (server.start()) {
170 int sig = Wt::WServer::waitForShutdown();
171 std::cerr <<
"Shutting down: (signal = " <<
sig <<
")" << std::endl;
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
Wt::WText * javaScriptError_
void addChatWidget()
Add another chat client.
SimpleChatServer & server_
const Wt::WEnvironment & env_
ChatApplication(const Wt::WEnvironment &env, SimpleChatServer &server)
Create a new instance.
std::unique_ptr< Wt::WTimer > timer_
std::unique_ptr< Wt::WApplication > createApplication(const Wt::WEnvironment &env, SimpleChatServer &server)
int main(int argc, char **argv)
std::unique_ptr< Wt::WApplication > createWidget(const Wt::WEnvironment &env, SimpleChatServer &server)