Wt examples  4.10.4
Classes | Functions
simpleChat.C File Reference
#include <Wt/WApplication.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WEnvironment.h>
#include <Wt/WPushButton.h>
#include <Wt/WServer.h>
#include <Wt/WText.h>
#include <Wt/WTimer.h>
#include "SimpleChatServer.h"
#include "PopupChatWidget.h"

Go to the source code of this file.

Classes

class  ChatApplication
 A chat demo application. More...
 
class  ChatWidget
 A chat application widget. More...
 

Functions

std::unique_ptr< Wt::WApplicationcreateApplication (const Wt::WEnvironment &env, SimpleChatServer &server)
 
std::unique_ptr< Wt::WApplicationcreateWidget (const Wt::WEnvironment &env, SimpleChatServer &server)
 
int main (int argc, char **argv)
 

Function Documentation

◆ createApplication()

std::unique_ptr<Wt::WApplication> createApplication ( const Wt::WEnvironment env,
SimpleChatServer server 
)

Definition at line 142 of file simpleChat.C.

144 {
145  return std::make_unique<ChatApplication>(env, server);
146 }

◆ createWidget()

std::unique_ptr<Wt::WApplication> createWidget ( const Wt::WEnvironment env,
SimpleChatServer server 
)

Definition at line 148 of file simpleChat.C.

149 {
150  return std::make_unique<ChatWidget>(env, server);
151 }

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 153 of file simpleChat.C.

154 {
155  Wt::WServer server(argc, argv, WTHTTP_CONFIGURATION);
156  SimpleChatServer chatServer(server);
157 
158  /*
159  * We add two entry points: one for the full-window application,
160  * and one for a widget that can be integrated in another page.
161  */
162  server.addEntryPoint(Wt::EntryPointType::Application,
163  std::bind(createApplication, std::placeholders::_1,
164  std::ref(chatServer)));
165  server.addEntryPoint(Wt::EntryPointType::WidgetSet,
166  std::bind(createWidget, std::placeholders::_1,
167  std::ref(chatServer)), "/chat.js");
168 
169  if (server.start()) {
170  int sig = Wt::WServer::waitForShutdown();
171  std::cerr << "Shutting down: (signal = " << sig << ")" << std::endl;
172  server.stop();
173  }
174 }
A simple chat server.
static WT_API int waitForShutdown()
std::unique_ptr< Wt::WApplication > createWidget(const Wt::WEnvironment &env, SimpleChatServer &server)
Definition: simpleChat.C:148
std::unique_ptr< Wt::WApplication > createApplication(const Wt::WEnvironment &env, SimpleChatServer &server)
Definition: simpleChat.C:142