Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) TestBroadcastServer

 

TestBroadcastServer is a web application to test the WtBroadcastServer and WtBroadcastServerClient in the form of an edit widget, that can be viewed and edited by multiple visitors at the same time.

 

TestBroadcastServer is rendered obsolete by TestServerPusher and TestTimedServerPusher.

 

 

 

 

 

 

Downloads

 

 

 

 

 

 

Older downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestBroadcastServer/ToolTestBroadcastServer.pro

 

include(../../WebApplication.pri)
include(../../Libraries/BigInteger.pri)
include(../../Libraries/BoostAll.pri)
include(../../Libraries/Wt.pri)

include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralWeb.pri)

include(../../Classes/CppWtBroadcastServer/CppWtBroadcastServer.pri)

#include(ToolTestBroadcastServer.pri)

SOURCES += wtmain.cpp \
    testbroadcastservermenudialog.cpp \
    testbroadcastserverwtmenudialog.cpp \
    testbroadcastserverwtmaindialog.cpp

HEADERS += \
    testbroadcastservermenudialog.h \
    testbroadcastserverwtmaindialog.h \
    testbroadcastserverwtmenudialog.h

 

 

 

 

 

./ToolTestBroadcastServer/testbroadcastservermenudialog.h

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#ifndef TESTBROADCASTSERVERMENUDIALOG_H
#define TESTBROADCASTSERVERMENUDIALOG_H

#include <string>
#include <vector>

#include "menudialog.h"

namespace ribi {
namespace ToolTestBroadcastServer {

///The GUI independent part of the menu
struct MenuDialog : public ::ribi::MenuDialog
{
  MenuDialog();

  About GetAbout() const noexcept;
  Help GetHelp() const noexcept;
  boost::shared_ptr<const Program> GetProgram() const noexcept;
  std::string GetVersion() const noexcept;
  std::vector<std::string> GetVersionHistory() const noexcept;

  private:
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ToolTestBroadcastServer
} //~namespace ribi

#endif // TESTBROADCASTSERVERMENUDIALOG_H

 

 

 

 

 

./ToolTestBroadcastServer/testbroadcastservermenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#include "about.h"
#include "richelbilderbeekprogram.h"
#include "testbroadcastservermenudialog.h"
#include "trace.h"

ribi::ToolTestBroadcastServer::MenuDialog::MenuDialog()
{
  #ifndef NDEBUG
  Test();
  #endif
}

int ribi::ToolTestBroadcastServer::MenuDialog::ExecuteSpecific(const std::vector<std::string>& /*argv*/) noexcept
{
  //const int argc = static_cast<int>(argv.size());
  std::cout << GetHelp() << '\n';
  return 1;
}

ribi::About ribi::ToolTestBroadcastServer::MenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "TestBroadcastServer",
    "tool to test WtBroadcastServer",
    "the 28th of April 2014",
    "2011-2014",
    "http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm",
    GetVersion(),
    GetVersionHistory()
  );
  return a;
}

ribi::Help ribi::ToolTestBroadcastServer::MenuDialog::GetHelp() const noexcept
{
  return ribi::Help(
    this->GetAbout().GetFileTitle(),
    this->GetAbout().GetFileDescription(),
    {

    },
    {

    }
  );
}

boost::shared_ptr<const ribi::Program> ribi::ToolTestBroadcastServer::MenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const ribi::Program> p(new ProgramTestBroadcastServer);
  assert(p);
  return p;

}

std::string ribi::ToolTestBroadcastServer::MenuDialog::GetVersion() const noexcept
{
  return "2.0";
}

std::vector<std::string> ribi::ToolTestBroadcastServer::MenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2011-07-27: Version 1.0: initial version",
    "2011-07-28: Version 1.1: adapted ToolTestBroadcastServer to fit within WtWebsite",
    "2011-08-01: Version 1.2: minor changes",
    "2014-04-28: Version 2.0: put in namespace ribi"
  };
}


#ifndef NDEBUG
void ribi::ToolTestBroadcastServer::MenuDialog::Test() noexcept
{
  {
    static bool is_tested = false;
    if (is_tested) return;
    is_tested = true;
  }
  TRACE("Starting ribi::ToolTestBroadcastServer::MenuDialog::Test");
  TRACE("Finished ribi::ToolTestBroadcastServer::MenuDialog::Test successfully");
}
#endif

 

 

 

 

 

./ToolTestBroadcastServer/testbroadcastserverwtmaindialog.h

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#ifndef WTTESTBROADCASTSERVERMAINDIALOG_H
#define WTTESTBROADCASTSERVERMAINDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <Wt/WContainerWidget>

#include "wtbroadcastserverclient.h"
#pragma GCC diagnostic pop

namespace Wt
{
  struct WLineEdit;
}

namespace ribi {
namespace ToolTestBroadcastServer {

///TestBroadcastServer its main dialog
struct WtMainDialog : public Wt::WContainerWidget, WtBroadcastServerClient
{
  WtMainDialog();

  private:
  ///The user interface
  struct Ui
  {
    Ui() : m_edit(0) {}
    Wt::WLineEdit * m_edit;
  } ui;

  ///The user changes the text in the Wt::WLineEdit
  void OnEditChanged();

  ///The server updates the page
  void UpdatePage();
};

} //~namespace ribi
} //~namespace ToolTestBroadcastServer


#endif // WTTESTBROADCASTSERVERMAINDIALOG_H

 

 

 

 

 

./ToolTestBroadcastServer/testbroadcastserverwtmaindialog.cpp

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#include "testbroadcastserverwtmaindialog.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>

#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>

#include "testbroadcastservermenudialog.h"
#include "wtbroadcastserver.h"
#include "wtaboutdialog.h"
#pragma GCC diagnostic pop

ribi::ToolTestBroadcastServer::WtMainDialog::WtMainDialog()
{
  this->clear();
  this->setContentAlignment(Wt::AlignCenter);
  ui.m_edit = new Wt::WLineEdit(this);
  ui.m_edit->keyWentUp().connect(this,&ribi::ToolTestBroadcastServer::WtMainDialog::OnEditChanged);
  ui.m_edit->setMinimumSize(400,Wt::WLength::Auto);
  UpdatePage();
}

void ribi::ToolTestBroadcastServer::WtMainDialog::OnEditChanged()
{
  WtBroadcastServer::GetInstance()->SetData(
    std::string(ui.m_edit->text().toUTF8()));
}

void ribi::ToolTestBroadcastServer::WtMainDialog::UpdatePage()
{
  boost::any any;
  WtBroadcastServer::GetInstance()->GetData(any);
  std::string text;
  try
  {
    text = boost::any_cast<std::string>(any);
  }
  catch (boost::bad_any_cast&)
  {
    text = "TestBroadcastServer";
  }
  ui.m_edit->setText(text.c_str());
}

 

 

 

 

 

./ToolTestBroadcastServer/testbroadcastserverwtmenudialog.h

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#ifndef WTTESTBROADCASTSERVERMENUDIALOG_H
#define WTTESTBROADCASTSERVERMENUDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <Wt/WContainerWidget>
#pragma GCC diagnostic pop

namespace ribi {
namespace ToolTestBroadcastServer {

struct WtMenuDialog : public Wt::WContainerWidget
{
  WtMenuDialog();
  private:
  void CheckResources();
  Wt::WWidget * CreateNewAboutDialog();
  Wt::WWidget * CreateNewMainDialog() const;
  Wt::WWidget * CreateNewWelcomeDialog() const;
};

} //~namespace ribi
} //~namespace ToolTestBroadcastServer

#endif // WTTESTBROADCASTSERVERMENUDIALOG_H

 

 

 

 

 

./ToolTestBroadcastServer/testbroadcastserverwtmenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#include "testbroadcastserverwtmenudialog.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLabel>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
#include <Wt/WMenuItem>

#include "testbroadcastservermenudialog.h"
#include "wtaboutdialog.h"
#include "wtautoconfig.h"
#include "testbroadcastserverwtmaindialog.h"
#include "wtbroadcastserver.h"
#include "wtbroadcastserverclient.h"
#pragma GCC diagnostic pop

ribi::ToolTestBroadcastServer::WtMenuDialog::WtMenuDialog()
{
this->setContentAlignment(Wt::AlignCenter);
  {
    Wt::WLabel * const title = new Wt::WLabel("TestBroadcastServer");
    title->setStyleClass("title");
    this->addWidget(title);
  }
  //Menu
  {
    Wt::WStackedWidget * const contents = new Wt::WStackedWidget;
    Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);
    //Using CSS styleclass is the best (only?) way to display the menu well
    menu->setStyleClass("menu");
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Welcome",
        CreateNewWelcomeDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Start",
        CreateNewMainDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "About",
        CreateNewAboutDialog());
      menu->addItem(item);
    }
    //Display menu on top
    this->addWidget(menu);
    this->addWidget(new Wt::WBreak);
    //Display contents below menu
    this->addWidget(contents);
  }
}

Wt::WWidget * ribi::ToolTestBroadcastServer::WtMenuDialog::CreateNewAboutDialog()
{
  About a = MenuDialog().GetAbout();
  a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());
  a.AddLibrary("WtBroadcastServer version: " + WtBroadcastServer::GetVersion());
  a.AddLibrary("WtBroadcastServerClient version: " + WtBroadcastServerClient::GetVersion());
  WtAboutDialog * const d = new WtAboutDialog(a,false);
  assert(d);
  return d;
}

Wt::WWidget * ribi::ToolTestBroadcastServer::WtMenuDialog::CreateNewMainDialog() const
{
  WtMainDialog * const d = new WtMainDialog;
  assert(d);
  return d;
}

Wt::WWidget * ribi::ToolTestBroadcastServer::WtMenuDialog::CreateNewWelcomeDialog() const
{
  Wt::WContainerWidget * dialog = new Wt::WContainerWidget;
  dialog->setContentAlignment(Wt::AlignCenter);
  dialog->addWidget(new Wt::WBreak);
  new Wt::WLabel("Welcome to TestBroadcastServer",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("TestBroadcastServer demonstrates how to view the same changing info",dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("from different browsers and/or computers",dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("using the WtBroadcastServer and WtBroadcastServerClient classes",dialog);
  return dialog;
}

 

 

 

 

 

./ToolTestBroadcastServer/wtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestBroadcastServer, tool to test WtBroadcastServer
Copyright (C) 2011-2014 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolTestBroadcastServer.htm
//---------------------------------------------------------------------------
#include <iostream>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <Wt/WApplication>
#include <Wt/WEnvironment>
#include <Wt/WText>

#include "wtautoconfig.h"
#include "wtbroadcastserver.h"
#include "testbroadcastserverwtmenudialog.h"
#pragma GCC diagnostic pop

struct WtApplication : public Wt::WApplication
{
  WtApplication(const Wt::WEnvironment& env)
  : WApplication(env)
  {
    setTitle("TestBroadcastServer");
    this->useStyleSheet("wt.css");
    root()->addWidget(new ribi::ToolTestBroadcastServer::WtMenuDialog);
  }
};

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
  return new WtApplication(env);
}

int main(int argc, char **argv)
{
  ribi::WtAutoConfig::SaveDefaultStylesheet();
  ribi::WtAutoConfig a(argc,argv,createApplication);
  return a.Run();
}

 

 

 

 

 

./ToolTestBroadcastServer/helgrind.sh

 

#!/bin/sh
valgrind --tool=helgrind --log-file=helgrind.txt ../ToolTestBroadcastServer-build-desktop/./ToolTestBroadcastServer

 

 

 

 

 

./ToolTestBroadcastServer/zip.sh

 

#!/bin/sh
#zip packs all the files to port into a single .zip file,
#minicking the same folder structure
#Folder structure
# *
#   * Classes
#     * CppAbout
#     * CppWtAboutDialog
#     * CppWtAutoConfig
#     * CppWtBroadcastServer
#   * Tools
#    * ToolTestBroadcastServer

echo "Removing old user information"
rm copy.txt
rm tmp.txt
rm ToolTestBroadcastServer.pro.user

echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppWtAboutDialog
mkdir temp_zip/Classes/CppWtAutoConfig
mkdir temp_zip/Classes/CppWtBroadcastServer

mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolTestBroadcastServer

echo "Copying files"
cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout
cp ../../Classes/CppWtAboutDialog/*.* temp_zip/Classes/CppWtAboutDialog
cp ../../Classes/CppWtAutoConfig/*.* temp_zip/Classes/CppWtAutoConfig
cp ../../Classes/CppWtBroadcastServer/*.* temp_zip/Classes/CppWtBroadcastServer

cp ../../Tools/ToolTestBroadcastServer/*.* temp_zip/Tools/ToolTestBroadcastServer



FILENAME=ToolTestBroadcastServerSource_1_2
ZIP_FILENAME=$FILENAME".zip"

echo "Remove previous zip"
rm $ZIP_FILENAME

#echo "Compressing files"
cd temp_zip
zip -r $FILENAME Classes
#zip -r $FILENAME Games
#zip -r $FILENAME Libraries
#zip -r $FILENAME Projects
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"

#Classes
rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppWtAboutDialog/*.*
rm temp_zip/Classes/CppWtAutoConfig/*.*
rm temp_zip/Classes/CppWtBroadcastServer/*.*
rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppWtAboutDialog
rmdir temp_zip/Classes/CppWtAutoConfig
rmdir temp_zip/Classes/CppWtBroadcastServer
rmdir temp_zip/Classes

#Tools
rm temp_zip/Tools/ToolTestBroadcastServer/*.*
rmdir temp_zip/Tools/ToolTestBroadcastServer
rmdir temp_zip/Tools
rm temp_zip/*.*
rmdir temp_zip
echo "Done"

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml