Update MQTTManager.cs #8

Closed
lh wants to merge 0 commits from lh/20250429 into main
Collaborator
No description provided.
lh added 1 commit 2025-04-29 12:05:07 +09:00
Update MQTTManager.cs
All checks were successful
Code Review / code-review (pull_request) Successful in 6s
b664497c79
Author
Collaborator

Raktbeej Code Review:

Summary:

위반 항목

  • None

리뷰 결과, 변경된 부분에서 C# 코드 컨벤션을 위반한 사항은 발견되지 않았습니다.

리팩토링 제안
이번 변경 사항에서는 하드코딩된 문자열 "simulation/435faabb-6183-4690-a81f-027dd96d5827/#"을 사용하는 부분이 있습니다. 만약 이 토픽이 여러 곳에서 반복적으로 사용된다면, 해당 문자열을 상수 또는 설정 파일로 빼내어 관리하는 것이 유지보수에 유리할 것입니다. 예를 들어 const string 또는 설정 파일을 활용할 수 있습니다.

// 상수로 사용
private const string SimulationTopic = "simulation/435faabb-6183-4690-a81f-027dd96d5827/#";

// 사용
SubscriptionTopic(client, SimulationTopic);

또는 설정 파일에서 읽어들이는 방식도 고려해 볼 수 있습니다.

Raktbeej Code Review: ## Summary: ▷ **위반 항목** - **None** 리뷰 결과, 변경된 부분에서 C# 코드 컨벤션을 위반한 사항은 발견되지 않았습니다. **리팩토링 제안** 이번 변경 사항에서는 하드코딩된 문자열 `"simulation/435faabb-6183-4690-a81f-027dd96d5827/#"`을 사용하는 부분이 있습니다. 만약 이 토픽이 여러 곳에서 반복적으로 사용된다면, 해당 문자열을 상수 또는 설정 파일로 빼내어 관리하는 것이 유지보수에 유리할 것입니다. 예를 들어 `const string` 또는 설정 파일을 활용할 수 있습니다. ```csharp // 상수로 사용 private const string SimulationTopic = "simulation/435faabb-6183-4690-a81f-027dd96d5827/#"; // 사용 SubscriptionTopic(client, SimulationTopic); ``` 또는 설정 파일에서 읽어들이는 방식도 고려해 볼 수 있습니다.
lh added 1 commit 2025-04-30 12:15:10 +09:00
webmanager
All checks were successful
Code Review / code-review (pull_request) Successful in 8s
60eae20b92
Author
Collaborator

Raktbeej Code Review:

Summary:

The provided code represents a diff from a pull request introducing various new files and modifications in an existing C# Unity project. Here's a summary of the main changes:

  1. WebConfig.json:

    • A new JSON configuration file for web settings added under Assets/StreamingAssets. It contains a config with a host, port, and access token.
  2. BaseSimulationMessage.cs:

    • A new C# class BaseSimulationMessage added under Assets/WorkSpace/LH.
    • This class is serializable and designed to hold simulation messages with properties like type, event, component_type, component_id, and timestamp.
    • An enum SimulationType is defined for different event types.
  3. MQTTManager.cs:

    • Enhancement of MQTTManager class with integration of BaseSimulationMessage.
    • Introduced a topic property with custom getter and setter.
    • Added UnsubscribeTopic method allowing the client to unsubscribe from MQTT topics.
    • Includes deserialization of received MQTT messages into BaseSimulationMessage objects using JsonConvert.DeserializeObject.
    • Corrected subscription method naming (SubscriptionTopic to SubscribeTopic).
  4. WebConfig.cs:

    • Introduction of classes WebConfigList and WebConfig.
    • These are used to model the structure of the configurations found in WebConfig.json.

These changes enhance network configuration handling and message processing within the Unity project. It leverages JSON for configurations and introduces new capabilities in the MQTTManager related to handling message topics and unsubscribing from them. The use of JSON deserialization allows easy manipulation of simulation messages.

Raktbeej Code Review: ## Summary: The provided code represents a diff from a pull request introducing various new files and modifications in an existing C# Unity project. Here's a summary of the main changes: 1. **WebConfig.json**: - A new JSON configuration file for web settings added under `Assets/StreamingAssets`. It contains a config with a host, port, and access token. 2. **BaseSimulationMessage.cs**: - A new C# class `BaseSimulationMessage` added under `Assets/WorkSpace/LH`. - This class is serializable and designed to hold simulation messages with properties like type, event, component_type, component_id, and timestamp. - An enum `SimulationType` is defined for different event types. 3. **MQTTManager.cs**: - Enhancement of `MQTTManager` class with integration of `BaseSimulationMessage`. - Introduced a `topic` property with custom getter and setter. - Added `UnsubscribeTopic` method allowing the client to unsubscribe from MQTT topics. - Includes deserialization of received MQTT messages into `BaseSimulationMessage` objects using `JsonConvert.DeserializeObject`. - Corrected subscription method naming (`SubscriptionTopic` to `SubscribeTopic`). 4. **WebConfig.cs**: - Introduction of classes `WebConfigList` and `WebConfig`. - These are used to model the structure of the configurations found in `WebConfig.json`. These changes enhance network configuration handling and message processing within the Unity project. It leverages JSON for configurations and introduces new capabilities in the MQTTManager related to handling message topics and unsubscribing from them. The use of JSON deserialization allows easy manipulation of simulation messages.
lh closed this pull request 2025-04-30 12:17:19 +09:00
All checks were successful
Code Review / code-review (pull_request) Successful in 8s

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: UVCXR/Simulation#8