// $Id$
//
-#include "transmitter.h"
+#include "plaqui/server/transmitter.h"
+#include <glibmm/timer.h>
#include <socket++/sockinet.h>
#include <string>
+#ifdef DEBUG
+# include <iostream>
+#endif // DEBUG
-using namespace Plaqui;
+using namespace std;
-Transmitter::Transmitter(std::string host, int port):
- Connection(sockbuf::sock_dgram) {
-#warning Not implemented!
+namespace PlaQui {
+
+namespace Server {
+
+Transmitter::~Transmitter(void) {
+#ifdef DEBUG
+ cerr << __FILE__ << ": destructor." << endl;
+#endif // DEBUG
+}
+
+Transmitter::Transmitter(const string& _host, const 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);
+ 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
+