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>
This commit is contained in:
parent
733c4de36e
commit
5a133a404e
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -46,9 +56,11 @@
|
||||
#include "timeconsumer.h"
|
||||
#include "chatconsumer.h"
|
||||
|
||||
#include "../shared/sctpchannels.h"
|
||||
|
||||
Client::Client(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, consumers(NumberOfChannels)
|
||||
, consumers(SctpChannels::NumberOfChannels)
|
||||
{
|
||||
setWindowTitle(tr("Multi-stream Client"));
|
||||
|
||||
@ -100,12 +112,12 @@ Client::Client(QWidget *parent)
|
||||
buttonBox->addButton(quitButton, QDialogButtonBox::AcceptRole);
|
||||
|
||||
QLabel *movieLabel = new QLabel(tr("Movie stream:"));
|
||||
consumers[Movie] = new MovieConsumer(this);
|
||||
consumers[SctpChannels::Movie] = new MovieConsumer(this);
|
||||
QLabel *timeLabel = new QLabel(tr("Time stream:"));
|
||||
consumers[Time] = new TimeConsumer(this);
|
||||
consumers[SctpChannels::Time] = new TimeConsumer(this);
|
||||
QLabel *chatLabel = new QLabel(tr("&Chat:"));
|
||||
consumers[Chat] = new ChatConsumer(this);
|
||||
chatLabel->setBuddy(consumers[Chat]->widget());
|
||||
consumers[SctpChannels::Chat] = new ChatConsumer(this);
|
||||
chatLabel->setBuddy(consumers[SctpChannels::Chat]->widget());
|
||||
|
||||
connect(hostCombo, &QComboBox::editTextChanged, this, &Client::enableConnectButton);
|
||||
connect(portLineEdit, &QLineEdit::textChanged, this, &Client::enableConnectButton);
|
||||
@ -116,8 +128,8 @@ Client::Client(QWidget *parent)
|
||||
connect(sctpSocket, &QSctpSocket::channelReadyRead, this, &Client::readDatagram);
|
||||
connect(sctpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
|
||||
this, SLOT(displayError(QAbstractSocket::SocketError)));
|
||||
connect(consumers[Time], &Consumer::writeDatagram, this, &Client::writeDatagram);
|
||||
connect(consumers[Chat], &Consumer::writeDatagram, this, &Client::writeDatagram);
|
||||
connect(consumers[SctpChannels::Time], &Consumer::writeDatagram, this, &Client::writeDatagram);
|
||||
connect(consumers[SctpChannels::Chat], &Consumer::writeDatagram, this, &Client::writeDatagram);
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout;
|
||||
mainLayout->addWidget(hostLabel, 0, 0);
|
||||
@ -127,10 +139,10 @@ Client::Client(QWidget *parent)
|
||||
mainLayout->addWidget(buttonBox, 2, 0, 1, 2);
|
||||
mainLayout->addWidget(movieLabel, 3, 0);
|
||||
mainLayout->addWidget(timeLabel, 3, 1);
|
||||
mainLayout->addWidget(consumers[Movie]->widget(), 4, 0);
|
||||
mainLayout->addWidget(consumers[Time]->widget(), 4, 1);
|
||||
mainLayout->addWidget(consumers[SctpChannels::Movie]->widget(), 4, 0);
|
||||
mainLayout->addWidget(consumers[SctpChannels::Time]->widget(), 4, 1);
|
||||
mainLayout->addWidget(chatLabel, 5, 0);
|
||||
mainLayout->addWidget(consumers[Chat]->widget(), 6, 0, 1, 2);
|
||||
mainLayout->addWidget(consumers[SctpChannels::Chat]->widget(), 6, 0, 1, 2);
|
||||
setLayout(mainLayout);
|
||||
|
||||
portLineEdit->setFocus();
|
||||
@ -143,7 +155,7 @@ Client::~Client()
|
||||
|
||||
void Client::connected()
|
||||
{
|
||||
consumers[Chat]->widget()->setFocus();
|
||||
consumers[SctpChannels::Chat]->widget()->setFocus();
|
||||
}
|
||||
|
||||
void Client::disconnected()
|
||||
@ -189,7 +201,7 @@ void Client::displayError(QAbstractSocket::SocketError socketError)
|
||||
.arg(sctpSocket->errorString()));
|
||||
}
|
||||
|
||||
connectButton->setEnabled(true);
|
||||
enableConnectButton();
|
||||
}
|
||||
|
||||
void Client::enableConnectButton()
|
||||
|
@ -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(const QByteArray &ba);
|
||||
|
||||
private:
|
||||
enum ChannelNumber {
|
||||
Movie = 0,
|
||||
Time = 1,
|
||||
Chat = 2,
|
||||
|
||||
NumberOfChannels = 3
|
||||
};
|
||||
|
||||
QVector<Consumer *> consumers;
|
||||
QSctpSocket *sctpSocket;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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()) {
|
||||
|
@ -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
|
||||
|
@ -34,3 +34,5 @@ qtHaveModule(widgets) {
|
||||
contains(QT_CONFIG, openssl-linked):SUBDIRS += securesocketclient
|
||||
contains(QT_CONFIG, sctp):SUBDIRS += multistreamserver multistreamclient
|
||||
}
|
||||
|
||||
EXAMPLE_FILES = shared
|
||||
|
62
examples/network/shared/sctpchannels.h
Normal file
62
examples/network/shared/sctpchannels.h
Normal file
@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** 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
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SCTPCHANNELS_H
|
||||
#define SCTPCHANNELS_H
|
||||
|
||||
enum SctpChannels {
|
||||
Movie = 0,
|
||||
Time = 1,
|
||||
Chat = 2,
|
||||
|
||||
NumberOfChannels = 3
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user