From ce3329047d378a14006ce74ec273ac59e3375303 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 12 May 2010 19:42:27 +0200 Subject: initial import of latest svn version --- src/net/pvsServiceBroadcast.cpp | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/net/pvsServiceBroadcast.cpp (limited to 'src/net/pvsServiceBroadcast.cpp') diff --git a/src/net/pvsServiceBroadcast.cpp b/src/net/pvsServiceBroadcast.cpp new file mode 100644 index 0000000..cf15b5b --- /dev/null +++ b/src/net/pvsServiceBroadcast.cpp @@ -0,0 +1,51 @@ +/* +# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# src/net/pvsServiceBroadcast.cpp +# - broadcast sessionname +# ----------------------------------------------------------------------------- +*/ +/********** COMPILE-TIME SETTINGS ***************/ + +#include "pvsServiceBroadcast.h" +#include "src/setup.h" +#include +#include "src/util/serviceDiscoveryUtil.h" + +PVSServiceBroadcast::PVSServiceBroadcast() +{ + _announce = NULL; + _timer = 0; + _broadcaster.bind(SD_PORT_CONSOLE); + _everyone = QHostAddress(QHostAddress::Broadcast); +} + +PVSServiceBroadcast::~PVSServiceBroadcast() +{ + if (_announce != NULL) delete _announce; + if (_timer != 0) this->killTimer(_timer); +} + +void PVSServiceBroadcast::setFingerprint(QByteArray sha1) +{ + if (_announce != NULL) _announce->clear(); + else _announce = new QByteArray(); + appendSdField(_announce, "hsh", QString(sha1.toBase64())); + appendSdField(_announce, "prt", SERVER_PORT); // TODO: maybe this has to come from somewhere else if configurable + appendSdField(_announce, "aut", "SHA1"); + if (_timer == 0) _timer = this->startTimer(SB_INTERVAL * 1000); +} + +void PVSServiceBroadcast::timerEvent(QTimerEvent *event) +{ + if (_announce == NULL) return; + _broadcaster.writeDatagram(*_announce, _everyone, SD_PORT_CLIENT); +} -- cgit v1.2.3-55-g7522