(C++) WtSimpleChat

January 25, 2018 · View on GitHub

 

 

 

 

 

(C++) WtSimpleChat

 

WtSimpleChat is an official Wt example developed by Emweb.

 

 

 

If you cannot get it too work, the problem and its solution is shown below.

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • Boost Boost: version 1.42
  • ?Qt Qt: version 4.7.0 (32 bit)
  • STL STL: GNU ISO C++ Library, version 4.4.5
  • Wt Wt: version 3.1.2

 

 

 

 

 

Qt project file: CppWtSimpleChat.pro

 


#------------------------------------------------- # # Project created by QtCreator 2011-04-10T11:16:42 # #------------------------------------------------- QT       += core QT       -= gui LIBS += -lwt -lwthttp -lboost_program_options QMAKE_CXXFLAGS += -DNDEBUG TARGET = CppWtSimpleChat CONFIG   += console CONFIG   -= app_bundle TEMPLATE = app SOURCES += simpleChat.cpp \   SimpleChatWidget.cpp \   SimpleChatServer.cpp HEADERS += \     SimpleChatWidget.h \     SimpleChatServer.h

 

 

 

 

 

SimpleChatServer.cpp

 


 

 

 

 

 

SimpleChatServer.h

 


 

 

 

 

 

SimpleChatWidget.cpp

 


 

 

 

 

 

SimpleChatWidget.h

 


 

 

 

 

 

simpleChat.cpp

 


 

 

 

 

 

Additional preparations

 

Added the following arguments to the Run Settings:

 


--docroot . --http-address 0.0.0.0 --http-port 8080

 

 

 

 

 

Output from the wthttpd server when it is not working

 


Starting /home/richel/qtsdk-2010.04/bin/Projects/Website/CppWtSimpleChat-build-desktop/CppWtSimpleChat... [2011-Apr-12 10:36:51.581110] 8824 - [notice] "Wt: initializing built-in httpd" [2011-Apr-12 10:36:51.581231] 8824 - [notice] "Reading Wt config file: /etc/wt/wt_config.xml (location = '/home/richel/qtsdk-2010.04/bin/Projects/Website/CppWtSimpleChat-build-desktop/CppWtSimpleChat')" [2011-Apr-12 10:36:51.581789] 8824 - [notice] "Started server: http://0.0.0.0:8080" [2011-Apr-12 10:36:55.029443] 8824 [/ gQop6M7Wgwi35eUo] [notice] "Session created (#sessions = 1)" Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24 127.0.0.1 - - [2011-Apr-12 10:36:55.030755] "GET / HTTP/1.1" 200 1836 127.0.0.1 - - [2011-Apr-12 10:36:55.103744] "GET /?wtd=gQop6M7Wgwi35eUo&request=script&rand=431931263 HTTP/1.1" 200 30085 127.0.0.1 - - [2011-Apr-12 10:36:55.138307] "GET /resources//themes/default/wt.css HTTP/1.1" 404 85 127.0.0.1 - - [2011-Apr-12 10:36:55.138488] "GET /resources/swfobject.js HTTP/1.1" 404 85 127.0.0.1 - - [2011-Apr-12 10:36:55.311107] "GET /favicon.ico HTTP/1.1" 404 85

 

Pressing F5 (Refresh) once, to check for runtime errors, adds the following

 


[2011-Apr-12 10:36:58.735773] 8824 [/ fmn6vnZeV8Ih3vIh] [notice] "Session created (#sessions = 2)" 127.0.0.1 - - [2011-Apr-12 10:36:58.736617] "GET / HTTP/1.1" 200 1836 Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24 127.0.0.1 - - [2011-Apr-12 10:36:58.790913] "GET /?wtd=fmn6vnZeV8Ih3vIh&request=script&rand=854652532 HTTP/1.1" 200 30092 127.0.0.1 - - [2011-Apr-12 10:36:58.930977] "GET /resources//themes/default/wt.css HTTP/1.1" 404 85 127.0.0.1 - - [2011-Apr-12 10:36:58.936669] "GET /simplechat.css HTTP/1.1" 304 0 127.0.0.1 - - [2011-Apr-12 10:36:58.984089] "GET /favicon.ico HTTP/1.1" 404 85 127.0.0.1 - - [2011-Apr-12 10:36:58.984100] "GET /resources/swfobject.js HTTP/1.1" 404 85

 

 

 

 

 

Solution when it is not working

 

Thanks to Koen Deforche and Wim Dumon for pointing me out the problem: the wthttpd server output with '404' denotes 'not found'. Put these files in place and it works! Or do not choose to do a 'Shadow Build'.