diff options
| author | Sebastian | 2010-05-12 19:42:27 +0200 |
|---|---|---|
| committer | Sebastian | 2010-05-12 19:42:27 +0200 |
| commit | ce3329047d378a14006ce74ec273ac59e3375303 (patch) | |
| tree | 782430f270b4c7aca1b35d5b7813518e3797c555 /src/net/pvsServiceBroadcast.cpp | |
| download | pvs-ce3329047d378a14006ce74ec273ac59e3375303.tar.gz pvs-ce3329047d378a14006ce74ec273ac59e3375303.tar.xz pvs-ce3329047d378a14006ce74ec273ac59e3375303.zip | |
initial import of latest svn version
Diffstat (limited to 'src/net/pvsServiceBroadcast.cpp')
| -rw-r--r-- | src/net/pvsServiceBroadcast.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
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 <cassert>
+#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);
+}
|
