Webserver written in C++ using websocketpp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a server written in C++  that uses websockets and json.
Websocket is provided by websocketpp and json by nlohmann / json.


The purpose of this server is to send a football (european soccer)
table to a webclient. The client can start a match, update how many
goals are scored and the table is updated accordingly.

My original intention was to design it for mobile devices so it is best
viewed when changing the browsers viewmode to those devices. In safari
the shortcut is alt+cmd+r to enter responsive mode. In chrome you must
enter the console first with alt+cmd+j first and then cmd+shift+m.
Firefox use alt+cmd+m.

I added a delay before a goal is registered and this works fine on
the desktop but it did not work so well on ios-devices. I think a
powersaving feature kicks in. So I have not pursued the issue but
have not changed the interface either.

Every time a goal is scored the server update a database, currently
postgresql, and if points needs to be added or taken away, it will
do so.

When changes are made they are pushed back to the client. The table
is sorted on the client.

JSON is used to transmit data. The client uses send(). The server
parse the string in om_message() and perform actions based on that.

When a client initially opens a websocket-connetion it always sends
the message {"type":"get table"} and the server sends the league
standings, current matches, finished matches, coming matches with an
assigned startdate back to the client.

When a goal is scored the client constructs a json-message with
the scoring home- or away-team, goals, current time and part of the
message is {"type":"goal"}. The server parses the json-message in a
try-catch and if it is a valid json the update the appropriate tables
and standings back.

All clients-connections are added to a std::set during on_open()
and this container is then traversed when updates are received from
the clients. So when a team score all connected clients receive
this information and all clients are thus updated.

I've written a javascript-client which can be found at