Wt examples: ChatWidget Class Reference

Wt examples 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ChatWidget Class Reference

A chat application widget. More...

Inheritance diagram for ChatWidget:
[legend]

## Public Member Functions
| ChatWidget (const Wt::WEnvironment &env, SimpleChatServer &server)

## Private Attributes
Wt::JSignal< Wt::WString > | login_

## Detailed Description

A chat application widget.

Definition at line 99 of file simpleChat.C.

## Constructor & Destructor Documentation

## ◆ ChatWidget()

ChatWidget::ChatWidget | ( | const Wt::WEnvironment & | env,
|  | SimpleChatServer & | server )

Definition at line 108 of file simpleChat.C.

109 : Wt::WApplication(env),
110 login_(this, "login")
111{
112 setCssTheme("");
113 useStyleSheet("chatwidget.css");
114 useStyleSheet("chatwidget_ie6.css", "lt IE 7");
115
116 messageResourceBundle().use(appRoot() + "simplechat");
117
118 const std::string *div = env.getParameter("div");
119 std::string defaultDiv = "div";
120 if (!div)
121 div = &defaultDiv;
122
123 if (div) {
124 setJavaScriptClass(*div);
125 std::unique_ptr<PopupChatWidget> chatWidgetPtr =
126 std::make_unique<PopupChatWidget>(server, *div);
127 PopupChatWidget *chatWidget = chatWidgetPtr.get();
128 bindWidget(std::move(chatWidgetPtr), *div);
129
130 login_.connect(chatWidget, &PopupChatWidget::setName);
131
132 std::string chat = javaScriptClass();
133 doJavaScript("if (window." + chat + "User) "
134 + chat + ".emit(" + chat + ", 'login', " + chat + "User);"
135 + "document.body.appendChild(" + chatWidget->jsRef() + ");");
136 } else {
137 std::cerr << "Missing: parameter: 'div'" << std::endl;
138 quit();
139 }
140}
ChatWidget::login_
Wt::JSignal< Wt::WString > login_
Definition simpleChat.C:105
PopupChatWidget
A popup chat widget.
Definition PopupChatWidget.h:21
PopupChatWidget::setName
void setName(const Wt::WString &name)
Definition PopupChatWidget.C:53

## Member Data Documentation

## ◆ login_

Wt::JSignal<Wt::WString> ChatWidget::login_
| private

Definition at line 105 of file simpleChat.C.

The documentation for this class was generated from the following file:

- simplechat/simpleChat.C