Logo
~Sockets~
~Examples~
~Contact~


ChatHandler.cpp

Go to the documentation of this file.
00001 //ChatHandler.cpp
00002 /*
00003 Copyright (C) 2004  Anders Hedstrom
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00020 //#include <stdio.h>
00021 
00022 #include "ChatSocket.h"
00023 #include "ChatHandler.h"
00024 
00025 
00026 
00027 
00028 ChatHandler::ChatHandler()
00029 :SocketHandler()
00030 {
00031 }
00032 
00033 
00034 ChatHandler::~ChatHandler()
00035 {
00036 }
00037 
00038 
00039 void ChatHandler::Talk(const std::string& name,const std::string& line)
00040 {
00041         std::string str = "\n";
00042         str += name + " says '" + line + "'\n";
00043 
00044         for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
00045         {
00046 //              SOCKET s = (*it).first;
00047                 Socket *p0 = (*it).second;
00048                 ChatSocket *p = dynamic_cast<ChatSocket *>(p0);
00049                 if (p)
00050                 {
00051                         p -> Send(str);
00052                 }
00053         }
00054 }
00055 
00056 
00057 void ChatHandler::Who(ChatSocket *p2)
00058 {
00059         for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
00060         {
00061 //              SOCKET s = (*it).first;
00062                 Socket *p0 = (*it).second;
00063                 ChatSocket *p = dynamic_cast<ChatSocket *>(p0);
00064                 if (p)
00065                 {
00066                         p2 -> Send(p -> GetName() + "\n");
00067                 }
00068         }
00069 }
00070 
00071 
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4