| Wt examples
    3.3.0
    | 
| Classes | |
| class | PopupChatWidget | 
| A popup chat widget.  More... | |
| class | ChatApplication | 
| A chat demo application.  More... | |
| class | ChatWidget | 
| A chat application widget.  More... | |
| class | ChatEvent | 
| Encapsulate a chat event.  More... | |
| class | SimpleChatServer | 
| A simple chat server.  More... | |
| class | SimpleChatWidget | 
| A self-contained chat widget.  More... | |
| Typedefs | |
| typedef boost::function< void(const ChatEvent &)> | ChatEventCallback | 
| Functions | |
| WApplication * | createApplication (const WEnvironment &env, SimpleChatServer &server) | 
| WApplication * | createWidget (const WEnvironment &env, SimpleChatServer &server) | 
| int | main (int argc, char **argv) | 
| ChatApplication::ChatApplication (const WEnvironment &env, SimpleChatServer &server) | |
| Create a new instance. | |
| void | ChatApplication::addChatWidget () | 
| Add another chat client. | |
| ChatWidget::ChatWidget (const WEnvironment &env, SimpleChatServer &server) | |
| typedef boost::function<void (const ChatEvent&)> ChatEventCallback | 
Definition at line 81 of file SimpleChatServer.h.
| void ChatApplication::addChatWidget | ( | ) |  [private] | 
Add another chat client.
Definition at line 63 of file simpleChat.C.
{
  SimpleChatWidget *chatWidget2 = new SimpleChatWidget(server_, root());
  chatWidget2->setStyleClass("chat");
}
| ChatApplication::ChatApplication | ( | const WEnvironment & | env, | 
| SimpleChatServer & | server | ||
| ) | 
Create a new instance.
Definition at line 41 of file simpleChat.C.
: WApplication(env), server_(server) { setTitle("Wt Chat"); useStyleSheet("chatapp.css"); messageResourceBundle().use(appRoot() + "simplechat"); root()->addWidget(new WText(WString::tr("introduction"))); SimpleChatWidget *chatWidget = new SimpleChatWidget(server_, root()); chatWidget->setStyleClass("chat"); root()->addWidget(new WText(WString::tr("details"))); WPushButton *b = new WPushButton("I'm schizophrenic ...", root()); b->clicked().connect(b, &WPushButton::hide); b->clicked().connect(this, &ChatApplication::addChatWidget); }
| ChatWidget::ChatWidget | ( | const WEnvironment & | env, | 
| SimpleChatServer & | server | ||
| ) | 
Definition at line 80 of file simpleChat.C.
: WApplication(env), login_(this, "login") { setCssTheme(""); useStyleSheet("chatwidget.css"); useStyleSheet("chatwidget_ie6.css", "lt IE 7"); const std::string *div = env.getParameter("div"); std::string defaultDiv = "div"; if (!div) div = &defaultDiv; if (div) { setJavaScriptClass(*div); PopupChatWidget *chatWidget = new PopupChatWidget(server, *div); bindWidget(chatWidget, *div); login_.connect(chatWidget, &PopupChatWidget::setName); std::string chat = javaScriptClass(); doJavaScript("if (window." + chat + "User) " + chat + ".emit(" + chat + ", 'login', " + chat + "User);" + "document.body.appendChild(" + chatWidget->jsRef() + ");"); } else { std::cerr << "Missing: parameter: 'div'" << std::endl; quit(); } }
| WApplication* createApplication | ( | const WEnvironment & | env, | 
| SimpleChatServer & | server | ||
| ) | 
Definition at line 110 of file simpleChat.C.
{
  return new ChatApplication(env, server);
}
| WApplication* createWidget | ( | const WEnvironment & | env, | 
| SimpleChatServer & | server | ||
| ) | 
Definition at line 116 of file simpleChat.C.
{
  return new ChatWidget(env, server);
}
| int main | ( | int | argc, | 
| char ** | argv | ||
| ) | 
Definition at line 121 of file simpleChat.C.
{
  Wt::WServer server(argv[0]);
  SimpleChatServer chatServer(server);
  server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
  /*
   * We add two entry points: one for the full-window application,
   * and one for a widget that can be integrated in another page.
   */
  server.addEntryPoint(Wt::Application,
                       boost::bind(createApplication, _1,
                                   boost::ref(chatServer)));
  server.addEntryPoint(Wt::WidgetSet,
                       boost::bind(createWidget, _1,
                                   boost::ref(chatServer)), "/chat.js");
  if (server.start()) {
    int sig = Wt::WServer::waitForShutdown();
    std::cerr << "Shutting down: (signal = " << sig << ")" << std::endl;
    server.stop();
  }
}
 1.7.5.1
 1.7.5.1