Wt examples  3.2.1
Classes | Typedefs | Functions
Chat example

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

WApplicationcreateApplication (const WEnvironment &env, SimpleChatServer &server)
WApplicationcreateWidget (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)

Detailed Description


Typedef Documentation

typedef boost::function<void (const ChatEvent&)> ChatEventCallback

Definition at line 81 of file SimpleChatServer.h.


Function Documentation

void ChatApplication::addChatWidget ( )
private

Add another chat client.

Definition at line 63 of file simpleChat.C.

{
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")));
chatWidget->setStyleClass("chat");
root()->addWidget(new WText(WString::tr("details")));
WPushButton *b = new WPushButton("I'm schizophrenic ...", root());
b->clicked().connect(b, &WPushButton::hide);
}
ChatWidget::ChatWidget ( const WEnvironment env,
SimpleChatServer server 
)

Definition at line 80 of file simpleChat.C.

: WApplication(env),
login_(this, "login")
{
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) {
PopupChatWidget *chatWidget = new PopupChatWidget(server, *div);
bindWidget(chatWidget, *div);
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()) {
std::cerr << "Shutting down: (signal = " << sig << ")" << std::endl;
server.stop();
}
}

Generated on Wed Jun 13 2012 for the C++ Web Toolkit (Wt) by doxygen 1.8.1