This commit is contained in:
2025-11-11 17:13:17 +09:00
parent c8a86e9081
commit dbd841c3a0
9 changed files with 71 additions and 682 deletions

View File

@@ -4,6 +4,7 @@ using Best.HTTP.Shared.PlatformSupport.Memory;
using Cysharp.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Simulator.Config;
using System;
using System.Collections.Generic;
using System.IO;
@@ -234,7 +235,8 @@ namespace UVC.Network
request.DownloadSettings = new Best.HTTP.Request.Settings.DownloadSettings() { ContentStreamMaxBuffered = 1024 * 1024 * 200 };
request.MethodType = method;
request.SetHeader("Content-Type", "application/json; charset=utf-8");
//if (useAuth) request.SetHeader("access-token", AuthService.Instance.Entiti.accessToken);
if (useAuth) request.SetHeader("Authorization", "Bearer " + Constants.ACESS_TOKEN);
//request.SetHeader("access-token", Constants.ACESS_TOKEN);
JObject headerObject = new JObject();
headerObject.Add("Content-Type", "application/json; charset=utf-8");

View File

@@ -338,9 +338,30 @@ namespace UVC.network
/// <remarks>
/// 이 메서드는 메시지를 로깅하고 해당 토픽에 등록된 모든 핸들러를 호출합니다.
/// </remarks>
private void OnTopic(MQTTClient client, SubscriptionTopic topic, string topicName, ApplicationMessage message)
private void OnTopic(MQTTClient client, SubscriptionTopic topic, string topicName, ApplicationMessage message)
{
DispatchTopic(() => OnTopicLogic(client, topic, topicName, message));
string payload = Encoding.UTF8.GetString(message.Payload.Data, message.Payload.Offset, message.Payload.Count);
//Debug.Log($"{payload}");
//DispatchTopic(() => OnTopicLogic(client, topic, topicName, message));
if (useWebSocket)
{
// WebGL: 스레드풀 없음 → 다음 프레임에 메인 스레드로 실행
OnTopicLogic(client, topic, topicName, message);
}
else
{
if (onBackgroundThread)
{
UniTask.RunOnThreadPool(() => OnTopicLogic(client, topic, topicName, message)).Forget();
}
else
{
if (PlayerLoopHelper.IsMainThread)
OnTopicLogic(client, topic, topicName, message);
else
UniTask.Post(() => OnTopicLogic(client, topic, topicName, message));
}
}
}
// 웹GL 대응: 스레드풀 미지원 시 메인 스레드로 포스트
@@ -372,6 +393,7 @@ namespace UVC.network
{
//Debug.Log($"MQTT OnTopicLogic isMainThread={PlayerLoopHelper.IsMainThread}");
string payload = Encoding.UTF8.GetString(message.Payload.Data, message.Payload.Offset, message.Payload.Count);
//Debug.Log($"{payload}");
//ULog.Debug($"MQTT OnTopic {topic.Filter.OriginalFilter} => {payload}");
#if !UNITY_WEBGL || UNITY_EDITOR
ServerLog.LogMqtt(MQTTDomain, MQTTPort.ToString(), topic.Filter.OriginalFilter, payload, DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"));