// vim: set noexpandtab tabstop=4 shiftwidth=4: //---------------------------------------------------------------------------- // PlaQui //---------------------------------------------------------------------------- // This file is part of PlaQui. // // PlaQui is free software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) any later // version. // // PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along // with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple // Place, Suite 330, Boston, MA 02111-1307 USA //---------------------------------------------------------------------------- // Creado: Sat Oct 18 18:18:36 2003 // Autores: Leandro Lucarella <llucare@fi.uba.ar> //---------------------------------------------------------------------------- // // $Id$ // #include "plaqui/server/transmitter.h" #include <glibmm/timer.h> #include <socket++/sockinet.h> #include <string> #ifdef DEBUG # include <iostream> #endif // DEBUG using namespace std; namespace PlaQui { namespace Server { Transmitter::~Transmitter(void) { #ifdef DEBUG cerr << __FILE__ << ": destructor." << endl; #endif // DEBUG } Transmitter::Transmitter(string& _host, Connection::Port& _port): Connection(sockbuf::sock_dgram, _host, _port) { #ifdef DEBUG cerr << __FILE__ << ": _host = " << _host << " | _port = " << _port << endl; #endif // DEBUG socket->connect(host.c_str(), port); // Reasigno el host y puerto bien, tanto de este objeto como los que se // environ para indicar su valor correcto. host = socket->peerhost(); port = socket->peerport(); _host = socket->peerhost(); _port = socket->peerport(); } /// \todo debría dar una excepción (?) void Transmitter::real_run(void) { #ifdef DEBUG cerr << __FILE__ << ": real_run()." << endl; #endif // DEBUG // No hace nada, porque solo actua cuando se manda algo con send(). while (!stop) { Glib::usleep(1000); } } void Transmitter::send(const string& data) { #ifdef DEBUG cerr << __FILE__ << ": send(data = " << data << ")." << endl; #endif // DEBUG socket << data << flush; } } // namespace Server } // namespace PlaQui