Example #1
0
int IrcClient::WaitResponse (int response )
{
  char buf[1024];
  IrcMessage msg;
  
  while (true)
    {
      int res = socket.ReadMessage ( buf );
      if (res > 0)
	{
	  std::printf ("IRC MESSAGE: %s\n", buf );
	  msg = IrcMessage ( 0, buf, true );

	  if ( (res = DispatchMessage ( msg )) != S_OK)
	    return res;
	  		   
	  if ( msg.GetResponse() == response ||
	       msg.GetResponse() >= 400  /* error */ )
	    return msg.GetResponse();
	}
    }
  return S_OK;
}
Example #2
0
int IrcClient::DispatchResponse ( const IrcMessage &msg )
{
  switch (msg.GetResponse ())
    {
    case 376: //End of MOTD command
      is_registered = true;
      if (events)
	events->OnRegistered ();
      break;
    }

  if (events)
    events->OnResponse ( msg );
  
  return S_OK;
}