Make GroovePlayer a singleton to avoid being created for each browser. Add login UI component to eventually hold landing screen. Actually start server with initial interface.

This commit is contained in:
Kevin Whitaker
2017-01-28 00:56:22 -05:00
parent 093f74a846
commit a60e2a0c34
6 changed files with 68 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
find_package(Wt REQUIRED)
find_package(Groove REQUIRED)
add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp)
add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp src/ui/LoginInterface.cpp)
target_link_libraries(arbitrateor ${Wt_LIBRARIES} ${GROOVE_LIBRARY})
install(TARGETS arbitrateor RUNTIME DESTINATION bin)

View File

@@ -18,3 +18,8 @@
*/
#include "GroovePlayer.h"
GroovePlayer::GroovePlayer()
{
}

View File

@@ -22,6 +22,15 @@
class GroovePlayer
{
public:
static GroovePlayer* getInstance() {
static GroovePlayer instance;
return &instance;
};
GroovePlayer(GroovePlayer const&) = delete;
void operator=(GroovePlayer const&) = delete;
private:
GroovePlayer();
};
#endif // GROOVEPLAYER_H

View File

@@ -18,3 +18,25 @@
*/
#include "WebInterface.h"
#include "ui/LoginInterface.h"
#include <Wt/WText>
struct WebInterface::internal
{
LoginInterface* loginUI;
};
WebInterface::WebInterface(const Wt::WEnvironment& env) : Wt::WApplication(env)
{
priv_int = new internal;
setTitle("Arbitrateor - Audio Jukebox");
priv_int->loginUI = new LoginInterface(this);
root()->addWidget(priv_int->loginUI);
}
void WebInterface::loginCompleted()
{
//Login completed, now bring up main inteface.
root()->removeWidget(priv_int->loginUI);
root()->addWidget(new Wt::WText("you did it"));
}

View File

@@ -21,9 +21,16 @@
#define WEBINTERFACE_H
#include <Wt/WApplication>
#include "GroovePlayer.h"
class WebInterface : public Wt::WApplication
{
public:
WebInterface(const Wt::WEnvironment& env);
void loginCompleted();
private:
struct internal;
internal* priv_int = 0;
};
#endif // WEBINTERFACE_H

View File

@@ -1,8 +1,30 @@
#include <iostream>
#include "WebInterface.h"
#include <Wt/WServer>
#include <Wt/WConfig.h>
#include "GroovePlayer.h"
Wt::WApplication* createApplication(const Wt::WEnvironment& env)
{
return new WebInterface(env);
}
int main ( int argc, char** argv )
{
std::cout << "Hello, world!" << std::endl;
return 0;
try {
Wt::WServer server(argv[0]);
server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
server.addEntryPoint(Wt::Application, createApplication);
if(server.start())
{
int sig = Wt::WServer::waitForShutdown(argv[0]);
server.stop();
}
return 0;
}
catch (Wt::WServer::Exception& e)
{
std::cerr << e.what() << "\n";
return 1;
}
}