Original C++ oatpp websocket examples are implemented through OATPP_CREATE_COMPONENT
and OATPP_COMPONENT
macros,
that are part of oatpp Dependency Injection (DI) framework reference.
The code structure of the examples with _COMPONENT
macros is often unclear to new users and a bit obscure about setting up the server and connection handlers using oatpp.
This repo contains refectored c++ examples of server and client without using dependency injection framework macros components.
git clone https://github.com/oatpp/oatpp
cd oatpp
git checkout tags/1.3.0
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<path-to-oatpp>/build/install
make all
make install
git clone https://github.com/oatpp/oatpp-websocket
cd oatpp-websocket
git checkout tags/1.3.0
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<path-to-oatpp-websocket>/build/install -Doatpp_DIR=<path-to-oatpp>/build/install/lib/cmake/oatpp-1.3.0/
make all
make install
git clone https://github.com/yeshasvitirupachuri/oatpp-websocket-server-client-example
cd oatpp-websocket-server-client-example
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -Doatpp_DIR=<path-to-oatpp>/build/install/lib/cmake/oatpp-1.3.0/ -Doatpp-websocket_DIR=<path-to-oatpp-websocket>/build/install/lib/cmake/oatpp-websocket-1.3.0/
make all
- Open a new terminal and go to the repo root directory
./build/server/oatpp-websocket-server-exe
- The server status can be checked by opening the following address in a web browser
http://localhost:8000/
- The client application needs an extra argument that is taken as the client name. In a new terminal run the client executable
./build/client/oatpp-websocket-client-exe Client#1