7 #ifndef SIMPLECHATSERVER_H_ 8 #define SIMPLECHATSERVER_H_ 10 #include <boost/noncopyable.hpp> 21 #include <boost/thread.hpp> 35 enum Type { Login, Logout, Rename, Message };
43 const Wt::WString&
user()
const {
return user_; }
47 const Wt::WString&
message()
const {
return message_; }
51 const Wt::WString&
data()
const {
return data_; }
57 const Wt::WString formattedHTML(
const Wt::WString& user,
58 Wt::TextFormat format)
const;
69 ChatEvent(
const Wt::WString& user,
const Wt::WString& message)
70 : type_(Message), user_(user), message_(message)
74 const Wt::WString& data = Wt::WString::Empty)
75 : type_(type), user_(user), data_(data)
114 bool disconnect(
Client *client);
120 bool login(
const Wt::WString& user);
124 void logout(
const Wt::WString& user);
128 bool changeName(
const Wt::WString& user,
const Wt::WString& newUser);
132 Wt::WString suggestGuest();
136 void sendMessage(
const Wt::WString& user,
const Wt::WString& message);
159 void postChatEvent(
const ChatEvent& event);
164 #endif // SIMPLECHATSERVER_H_
Type type() const
Get the event type.
boost::recursive_mutex mutex_
std::map< Client *, ClientInfo > ClientMap
ChatEventCallback eventCallback
const Wt::WString & data() const
Get the extra data for this event.
Encapsulate a chat event.
std::set< Wt::WString > UserSet
Typedef for a collection of user names.
Type
Enumeration for the event type.
boost::function< void(const ChatEvent &)> ChatEventCallback
ChatEvent(const Wt::WString &user, const Wt::WString &message)
const Wt::WString & message() const
Get the message of the event.
ChatEvent(Type type, const Wt::WString &user, const Wt::WString &data=Wt::WString::Empty)
const Wt::WString & user() const
Get the user who caused the event.