1 // ServerConnection.C -*- C++ -*-
2 // Copyright (c) 1997, 1998 Etienne BERNARD
3 // Copyright (C) 2002 Clinton Ebadi
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "ServerConnection.H"
30 ServerConnection::ServerConnection(Bot *b, Server *s, String localIP)
31 : Connection(s->getHostName(),
32 s->getPort(), localIP),
35 queue(new ServerQueue(&socket, b->debug)),
36 pingTime(0), lag(0), serverLastSpoken(time(0)),
42 ServerConnection::~ServerConnection()
48 ServerConnection::connect()
50 if (!socket.connect())
53 socket.setNonBlocking();
55 if (server->getPassword().length() != 0)
56 queue->sendPass(server->getPassword());
57 queue->sendNick(bot->wantedNickName);
58 queue->sendUser(bot->userName, bot->ircName);
66 ServerConnection::handleInput()
68 String line = socket.readLine();
70 if (line.length() == 0)
74 std::cout << line << "\n";
76 serverLastSpoken = time(0);
78 Parser::parseLine(this, line);