ircproxy  The Ultimate Cyborg

NickPair Class Reference

#include <NickPair.h>

List of all members.


Detailed Description

An input/output nick pair.

Definition at line 31 of file NickPair.h.


Public Member Functions

 NickPair (std::ostream &session)
 Create a NickPair instance for the session session.
void send_nick (std::string const &nick)
 Send a new NICK message to the socket.
bool nick_received (std::string const &nick)
 Process own nick changes.
void inuse (std::string const &nick)
 Called when a 433 is received from the server.
std::string const & in_nick (void) const
 Returns the last NICK received.
std::string const & out_nick (void) const
 Returns the last NICK sent.

Private Attributes

std::ostream & M_session
 The socket for which this nick pair is being kept.
std::string M_in_nick
 The last NICK received from the socket.
std::string M_out_nick
 The last NICK sent to the socket.
std::deque< std::string > M_out_nicks
 Unconfirmed outgoing nicks.

Constructor & Destructor Documentation

NickPair::NickPair ( std::ostream &  session  )  [inline]

Create a NickPair instance for the session session.

Definition at line 40 of file NickPair.h.

00040 : M_session(session) { }


Member Function Documentation

void NickPair::send_nick ( std::string const &  nick  ) 

Send a new NICK message to the socket.

Definition at line 19 of file NickPair.cc.

References DoutEntering, M_out_nick, M_out_nicks, and M_session.

Referenced by inuse(), ServerSession::new_message_received(), Authentication::send_authentication(), and ServerSession::send_nick_write_event().

00020 {
00021   DoutEntering(dc::debug, "NickPair::send_nick(\"" << nick << "\")");
00022   if (!M_out_nicks.empty() && M_out_nicks.back() == nick)
00023   {
00024     Dout(dc::notice, "The last nick sent to the server was the same! Ignoring request.");
00025     return;
00026   }
00027   M_session << "NICK " << nick << "\r\n";
00028   M_out_nick = nick;
00029   M_out_nicks.push_back(nick);
00030 }

bool NickPair::nick_received ( std::string const &  nick  ) 

Process own nick changes.

Called when a new NICK was received from the server.

Returns:
True if the NICK reflected a nick change of myself.

Definition at line 38 of file NickPair.cc.

References DoutEntering, M_in_nick, and M_out_nicks.

Referenced by ServerSession::new_message_received(), and Authentication::send_authentication().

00039 {
00040   DoutEntering(dc::debug, "NickPair::nick_received(\"" << nick << "\")");
00041   if (M_out_nicks.empty() || M_out_nicks.front() != nick)
00042   {
00043     Dout(dc::debug, "Not my nick.");
00044     return false;
00045   }
00046   M_out_nicks.pop_back();
00047   M_in_nick = nick;
00048   if (M_out_nicks.empty())
00049   {
00050     Dout(dc::notice, "NickPair::M_out_nicks is empty. Current nick is now \"" << nick << "\".");
00051   }
00052   return true;
00053 }

void NickPair::inuse ( std::string const &  nick  ) 

Called when a 433 is received from the server.

Definition at line 56 of file NickPair.cc.

References ASSERT, DoutEntering, M_out_nicks, and send_nick().

Referenced by Identity::new_server_message_received().

00057 {
00058   DoutEntering(dc::debug, "NickPair::inuse(\"" << nick << "\")");
00059   ASSERT(!M_out_nicks.empty());
00060   ASSERT(M_out_nicks.front() == nick);
00061   M_out_nicks.pop_back();
00062   if (M_out_nicks.empty())
00063   {
00064     std::string new_nick(nick);
00065     new_nick += '_';                    // FIXME
00066     ASSERT(new_nick != nick);
00067     send_nick(new_nick);
00068   }
00069 }

std::string const& NickPair::in_nick ( void   )  const [inline]

Returns the last NICK received.

Definition at line 47 of file NickPair.h.

References M_in_nick.

Referenced by Matcher_noarg::match_impl(), ServerSession::new_message_received(), and Identity::new_server_message_received().

00047 { return M_in_nick; }

std::string const& NickPair::out_nick ( void   )  const [inline]

Returns the last NICK sent.

Definition at line 50 of file NickPair.h.

References M_out_nick.

Referenced by ServerConnection::send_pong_and_mode().

00050 { return M_out_nick; }


Member Data Documentation

std::ostream& NickPair::M_session [private]

The socket for which this nick pair is being kept.

Definition at line 33 of file NickPair.h.

Referenced by send_nick().

std::string NickPair::M_in_nick [private]

The last NICK received from the socket.

Definition at line 34 of file NickPair.h.

Referenced by in_nick(), and nick_received().

std::string NickPair::M_out_nick [private]

The last NICK sent to the socket.

Definition at line 35 of file NickPair.h.

Referenced by out_nick(), and send_nick().

std::deque<std::string> NickPair::M_out_nicks [private]

Unconfirmed outgoing nicks.

Definition at line 36 of file NickPair.h.

Referenced by inuse(), nick_received(), and send_nick().


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

Copyright © 2005-2007 Carlo Wood.  All rights reserved.