Commit 0f4197f4 authored by Sylvain Renault's avatar Sylvain Renault
Browse files

New version in C# with complete visual studio project.

parent eeca8fdf
Loading
Loading
Loading
Loading
+43 −1
Original line number Diff line number Diff line
@@ -30,6 +30,34 @@ What you need:
2.	Installed openapi generator with npm: https://openapi-generator.tech/docs/installation/
3.	Optional: Installed docker (recommanded): https://www.docker.com/get-started 

## Auto-generate client code for WS

Use/define following setup for the config file `openapitools.json`:

```
{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "7.6.0",
    "generators":{
      "python": {
     "generatorName": "python",
     "output": "./generated_wa_client",
     "inputSpec": "./openapi/API/worldanalysis/worldanalysisopenapi.yaml",
     "additionalProperties": {
      "packageName": "ETSI.ARF.OpenAPI.WorldAnalysis"
     }
     }
    }
  }
}
```

Open a command shell and execute:
```
  npx openapi-generator-cli generate
```

## Installing the python module on your local computer

@@ -40,7 +68,21 @@ conda create -n openapi
conda activate openapi
```

Install the common apckae for async WebSockets:
Install the World Analysis OpenAPI:

```
pip install .\generated_wa_client
```

In case of not having the pip installed for your cml you can use following line:

```
py -m pip install .\generated_wa_client
```

## Installing the python module for WebSockets on your local computer

Install the common package for async WebSockets:

```
pip install websockets

openapi @ 7e50e43e

Original line number Diff line number Diff line
Subproject commit 073fd7213fd9e6ebc2f8a47d628a650de30c8bc4
Subproject commit 7e50e43e90a8dcd958944e8e9ceda05c7668db48
+34 −0
Original line number Diff line number Diff line
//
// ARF - Augmented Reality Framework (ETSI ISG ARF)
//
// Copyright 2024 ETSI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2024
//

namespace ETSI.ARF.WorldStorage
{
    public class WorldStorageServer
    {
        public string serverName = "myServerName";
        public string company = "";
        public string basePath = "https://";
        public int port = 8080;

        public WorldStorageUser currentUser = null;

        public string URI => port == 0 ? basePath : basePath + ":" + port.ToString();
    }
}
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
//
// ARF - Augmented Reality Framework (ETSI ISG ARF)
//
// Copyright 2024 ETSI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2024
//

namespace ETSI.ARF.WorldStorage
{
    public class WorldStorageUser
    {
        public string userName = "myName";
        public string company = "";
        public string UUID = System.Guid.Empty.ToString();
    }
}
 No newline at end of file
+38 −0
Original line number Diff line number Diff line
using System;
using System.Collections;
using System.Collections.Generic;

namespace ETSI.ARF.OpenAPI.WorldAnalysis
{
    /// <summary>
    /// Simple class to debug the requests
    /// </summary>
    public class BaseClient
    {
        static public bool EnableClientLog = true;
        public string lastJsonText;
        public long lastPayload;

        protected void _prepareRequest(ETSI.ARF.OpenAPI.WorldAnalysis.IHttpClient client, System.Net.Http.HttpRequestMessage request, string url)
        {
            if (EnableClientLog)
            {
                Console.WriteLine("[REST][URL] Send request: " + client.BaseAddress + url);
                Console.WriteLine("[REST][URL] Send request: " + request);
            }
        }

        protected void _processResponse(ETSI.ARF.OpenAPI.WorldAnalysis.IHttpClient client, System.Net.Http.HttpResponseMessage response)
        {
            lastJsonText = response.Content.ReadAsStringAsync().Result.ToString();
            lastPayload = response.Content.Headers.ContentLength.Value;

            var status_ = (int)response.StatusCode;

            if (EnableClientLog)
            {
                Console.WriteLine("[REST][Data] Status: " + status_ + " Response: " + client.BaseAddress + " Len: " + lastPayload + " JSON: " + lastJsonText);
            }
        }
    }
}
 No newline at end of file
Loading