【问题标题】:C++ HTTP server with angular (Typescript on client-side) [closed]带角度的C++ HTTP服务器(客户端的Typescript)[关闭]
【发布时间】:2018-11-17 13:41:58
【问题描述】:

我正在开发一个 AngularCLI 项目(打字稿),我是新手。客户端是每 70 毫秒更新一次的图片和一些相机设置。 到目前为止,我曾经有一个本地文件,其中大约有 3000 张图像,而我所要做的就是一次显示一张。很快,该应用程序将不得不在相机的 IP 上运行。有了这个应用程序,我们希望能够做两件事:

首先:更改应用程序上的一些设置;发送一个 HTTP Post,服务器会在某个地址上更改相机的设置。

第二步:发送一个 HTTP Get,服务器会去某个地址获取最后一张图片,所以我们会将它显示在画布上。下面的代码显示了我在说什么:

    // called every 70ms
  public drawCanvas(): void {

    // Change this part
    if (this._camera.state === "video") {
      this._pictureNumberVideo++;
      if (this._pictureNumberVideo === 3024) {
        this._pictureNumberVideo = 0;
      }
      this._image.src = '../assets/img/gifColor/frame_' + this._pictureNumberVideo + '_delay-0.1s.png';
    }

    // I want something like this
    // this._image.src = HTTP GET IMAGE 

    this._image.onload = () => {
      this._canvaVideo.width = this._image.width + BORDER;
      this._canvaVideo.height = this._image.height + BORDER;
      this._contextVideo.drawImage(this._image, BORDER / 2, BORDER / 2);
    };
  }

问题是我必须制作一个基本的 HTTP 服务器来处理 C++ 中的 HTTP Get 和 Post,我不知道我应该如何做或使用什么??

【问题讨论】:

  • 按原样,这对于 SO 格式来说太宽泛了。
  • C/C++ 不是一种语言。 C 和 C++ 是不同的语言。您问的是哪种语言?
  • 我更喜欢 C++ @FrançoisAndrieux

标签: c++ angular server socket.io client-server


【解决方案1】:

我已成功使用以下库从 C++ 公开 API:https://github.com/eidheim/Simple-Web-Server

还有新的Boost.Beast 库允许C++ 程序提供Web 资源。

然后,对于 json 解析,我已经成功使用了 Nlohmann Json JSON 库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 2019-01-29
    相关资源
    最近更新 更多