diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2016-08-03 09:50:55 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2016-08-03 11:46:21 +0000 |
commit | 5a133a404ebaa5233d5370ace10ba9532b9c6adc (patch) | |
tree | 9544da1252cf7d7aff1d195186c160235bf5c49b /examples/network/multistreamserver | |
parent | 733c4de36e71fa58dc444a181d725bfa46699a16 (diff) |
Polish SCTP examples
- Introduce a common header file for client and server;
- Update license headers;
- Fix minor issues.
Change-Id: I3fc42fd5ba32141c702fc6679a27bf0b6a16fd26
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'examples/network/multistreamserver')
-rw-r--r-- | examples/network/multistreamserver/chatprovider.cpp | 14 | ||||
-rw-r--r-- | examples/network/multistreamserver/chatprovider.h | 14 | ||||
-rw-r--r-- | examples/network/multistreamserver/main.cpp | 14 | ||||
-rw-r--r-- | examples/network/multistreamserver/movieprovider.cpp | 14 | ||||
-rw-r--r-- | examples/network/multistreamserver/movieprovider.h | 14 | ||||
-rw-r--r-- | examples/network/multistreamserver/provider.h | 14 | ||||
-rw-r--r-- | examples/network/multistreamserver/server.cpp | 30 | ||||
-rw-r--r-- | examples/network/multistreamserver/server.h | 22 | ||||
-rw-r--r-- | examples/network/multistreamserver/timeprovider.cpp | 16 | ||||
-rw-r--r-- | examples/network/multistreamserver/timeprovider.h | 14 |
10 files changed, 131 insertions, 35 deletions
diff --git a/examples/network/multistreamserver/chatprovider.cpp b/examples/network/multistreamserver/chatprovider.cpp index 9a88d491ab..a6ba9c6a27 100644 --- a/examples/network/multistreamserver/chatprovider.cpp +++ b/examples/network/multistreamserver/chatprovider.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/network/multistreamserver/chatprovider.h b/examples/network/multistreamserver/chatprovider.h index 912101ec34..b6ff61a917 100644 --- a/examples/network/multistreamserver/chatprovider.h +++ b/examples/network/multistreamserver/chatprovider.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/network/multistreamserver/main.cpp b/examples/network/multistreamserver/main.cpp index 04350cd13d..ae201f6b82 100644 --- a/examples/network/multistreamserver/main.cpp +++ b/examples/network/multistreamserver/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/network/multistreamserver/movieprovider.cpp b/examples/network/multistreamserver/movieprovider.cpp index cc534e6f40..335038a515 100644 --- a/examples/network/multistreamserver/movieprovider.cpp +++ b/examples/network/multistreamserver/movieprovider.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/network/multistreamserver/movieprovider.h b/examples/network/multistreamserver/movieprovider.h index d6d8fb7449..46de20a648 100644 --- a/examples/network/multistreamserver/movieprovider.h +++ b/examples/network/multistreamserver/movieprovider.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/network/multistreamserver/provider.h b/examples/network/multistreamserver/provider.h index c6ec612275..5be14d5ed8 100644 --- a/examples/network/multistreamserver/provider.h +++ b/examples/network/multistreamserver/provider.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/examples/network/multistreamserver/server.cpp b/examples/network/multistreamserver/server.cpp index 1fb18e80b9..3b06c0fd37 100644 --- a/examples/network/multistreamserver/server.cpp +++ b/examples/network/multistreamserver/server.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2015 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -47,9 +57,11 @@ #include "timeprovider.h" #include "chatprovider.h" +#include "../shared/sctpchannels.h" + Server::Server(QWidget *parent) : QDialog(parent) - , providers(NumberOfChannels) + , providers(SctpChannels::NumberOfChannels) { setWindowTitle(tr("Multi-stream Server")); @@ -59,15 +71,15 @@ Server::Server(QWidget *parent) statusLabel = new QLabel; QPushButton *quitButton = new QPushButton(tr("Quit")); - providers[Movie] = new MovieProvider(this); - providers[Time] = new TimeProvider(this); - providers[Chat] = new ChatProvider(this); + providers[SctpChannels::Movie] = new MovieProvider(this); + providers[SctpChannels::Time] = new TimeProvider(this); + providers[SctpChannels::Chat] = new ChatProvider(this); connect(sctpServer, &QSctpServer::newConnection, this, &Server::newConnection); connect(quitButton, &QPushButton::clicked, this, &Server::accept); - connect(providers[Movie], &Provider::writeDatagram, this, &Server::writeDatagram); - connect(providers[Time], &Provider::writeDatagram, this, &Server::writeDatagram); - connect(providers[Chat], &Provider::writeDatagram, this, &Server::writeDatagram); + connect(providers[SctpChannels::Movie], &Provider::writeDatagram, this, &Server::writeDatagram); + connect(providers[SctpChannels::Time], &Provider::writeDatagram, this, &Server::writeDatagram); + connect(providers[SctpChannels::Chat], &Provider::writeDatagram, this, &Server::writeDatagram); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(statusLabel); diff --git a/examples/network/multistreamserver/server.h b/examples/network/multistreamserver/server.h index 6d01f7a238..d9a38e61a4 100644 --- a/examples/network/multistreamserver/server.h +++ b/examples/network/multistreamserver/server.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -71,14 +81,6 @@ private slots: void writeDatagram(QSctpSocket *to, const QByteArray &ba); private: - enum ChannelNumber { - Movie = 0, - Time = 1, - Chat = 2, - - NumberOfChannels = 3 - }; - QVector<Provider *> providers; QSctpServer *sctpServer; QList<QSctpSocket *> connections; diff --git a/examples/network/multistreamserver/timeprovider.cpp b/examples/network/multistreamserver/timeprovider.cpp index 043810cdf3..fb50baac26 100644 --- a/examples/network/multistreamserver/timeprovider.cpp +++ b/examples/network/multistreamserver/timeprovider.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -55,6 +65,8 @@ void TimeProvider::readDatagram(QSctpSocket &from, const QByteArray &ba) QTime clientTime; in_ds >> clientTime; + // Send response only if a displayed part of the time is changed. + // So, sub-second differences are ignored. if (!clientTime.isValid() || curTime.second() != clientTime.second() || curTime.minute() != clientTime.minute() || curTime.hour() != clientTime.hour()) { diff --git a/examples/network/multistreamserver/timeprovider.h b/examples/network/multistreamserver/timeprovider.h index b57c066c24..f99cdbc717 100644 --- a/examples/network/multistreamserver/timeprovider.h +++ b/examples/network/multistreamserver/timeprovider.h @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are |