// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example magic8ball
    \ingroup qtgrpc-examples
    \examplecategory {Networking}
    \meta tag {network,protobuf,grpc}
    \title Magic 8 Ball

    \brief Creating a HTTP2 connection between a Qt GRPC client and
    a C++ gRPC server.

    Magic 8 ball shows an answer it receives from a server:
    \image answer.webp

    Magic 8 ball has the following components:
    \list
    \li \c magic8ball Qt GRPC client application that includes
        the \l {qt_add_protobuf}{qt_add_protobuf()} and
        \l {qt_add_grpc}{qt_add_grpc()}
        CMake functions for message and service Qt code generation.
    \li \c SimpleGrpcServer application that calls C++ gRPC plugin
        for generating server code and implementing simple server
        logic.
    \endlist

    \note you need the C++ gRPC plugin installed.
    Find details here: \l {Module prerequisites}

    Both components use generated messages from the protobuf schema
    described in the \c {exampleservice.proto} file:
    \quotefromfile magic8ball/proto/exampleservice.proto
    \skipto syntax = "proto3";
    \printuntil

    The client application binds on the \c localhost with port
    \c 50051:
    \quotefromfile magic8ball/clientservice.cpp
    \skipto QUrl url("http://localhost:50051", QUrl::StrictMode);
    \printuntil | QGrpcInsecureCallCredentials()));

    And sends a request to the server part:
    \quotefromfile magic8ball/clientservice.cpp
    \skipto void ClientService::sendRequest()
    \printuntil }

    Click the \uicontrol {Ask question} button to send
    the request to the SimpleGrpcServer application.

    The SimpleGrpcServer application chooses a random answer from
    the list of answers and sends the data to the client's port.
    \quotefromfile magic8ball/grpc_server_example/serverrunner.cpp
    \skipto Status ExampleServiceServiceImpl::answerMethod
    \printuntil }

    After receiving a response the client application shows the answer.

*/
