00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef CLIENTSESSION_H
00017 #define CLIENTSESSION_H
00018
00019 #ifndef USE_PCH
00020 #include <libcw/sock.h>
00021 #include <boost/shared_ptr.hpp>
00022 #include <string>
00023 #include <deque>
00024 #include <map>
00025 #include "debug.h"
00026 #include <libcw/events.h>
00027 #endif
00028
00029 #include "IdentityReference.h"
00030 #include "ClientSessionInput.h"
00031 #include "ClientSessionOutput.h"
00032 #include "UserAnswer.h"
00033 #include "DestructEvent.h"
00034 #include "Nick.h"
00035 #include "Index.h"
00036
00037 class MessageIn;
00038
00039
00040
00041
00042
00043
00044
00045 class ClientSession : public Index<ClientSession>, public IdentityReference, public sock_dtct<ClientSessionInput, ClientSessionOutput>,
00046 public virtual event_client_ct {
00047 public:
00048
00049 typedef std::map<std::string, boost::shared_ptr<Target>, IRC_less> private_targets_type;
00050
00051 typedef target_hold_map_type joined_channels_type;
00052
00053 private:
00054 std::string M_in_nick;
00055 bool M_queue_messages;
00056 std::deque<ClientMessageIn> M_msg_queue;
00057 bool M_first_nick;
00058 private_targets_type M_private_targets;
00059 joined_channels_type M_joined_channels;
00060
00061 public:
00062 UserAnswerEventServer user_answer_event_server;
00063 DestructEventServer destruct_event_server;
00064
00065 public:
00066
00067 ClientSession(void) : event_client_ct(), M_queue_messages(false), M_first_nick(true)
00068 { Dout(dc::objects, "Constructing ClientSession() " << *this); }
00069
00070 ~ClientSession();
00071
00072 public:
00073
00074 void fatal_error(char const* error_msg);
00075
00076
00077 void new_client_nick_received(std::string const& nick);
00078
00079
00080 std::string const& client_in_nick(void) const { return M_in_nick; }
00081
00082
00083 std::string const& client_out_nick(void) const { return M_in_nick; }
00084
00085
00086 void process_message(ClientMessageIn const& msg);
00087
00088
00089 void queue_message(ClientMessageIn const& msg);
00090
00091
00092 void start_queuing_messages(void);
00093
00094
00095 void stop_queuing_messages(DestructEventType const&);
00096
00097 void add_private_target(boost::shared_ptr<Target> const& target);
00098 void del_private_target(std::string const& target_name);
00099
00100
00101 private_targets_type& private_targets(void) { return M_private_targets; }
00102
00103
00104 private_targets_type const& private_targets(void) const { return M_private_targets; }
00105
00106
00107 joined_channels_type& joined_channels(void) { return M_joined_channels; }
00108
00109
00110 joined_channels_type const& joined_channels(void) const { return M_joined_channels; }
00111
00112
00113 void create_private_target(std::string const& target_name, Network& network);
00114
00115
00116 void queue_msg(MessageOut const& msgout);
00117
00118
00119 void queue_msg_as_is(ServerMessageIn const& msg);
00120
00121
00122 void queue_msg_me_as_is(ServerMessageIn const& msg);
00123
00124
00125 void serversession_lost(void);
00126
00127
00128 boost::shared_ptr<Nick> get_nick(std::string const& nick_name, bool create = false);
00129
00130 protected:
00131
00132 virtual void new_message_received(ClientMessageIn const&);
00133 };
00134
00135 #endif // CLIENTSESSION_H