Data 패키지 개선
This commit is contained in:
@@ -407,7 +407,7 @@ namespace UVC.Network
|
||||
headerObject.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
}
|
||||
//Debug.Log($"RequestWithDuration APIToken :{AuthService.Instance.Entiti.accessToken}");
|
||||
//ULog.Debug($"RequestWithDuration APIToken :{AuthService.Instance.Entiti.accessToken}");
|
||||
//if (useAuth) request.SetHeader("access-token", AuthService.Instance.Entiti.accessToken);
|
||||
if (body != null)
|
||||
{
|
||||
@@ -472,7 +472,7 @@ namespace UVC.Network
|
||||
/// </example>
|
||||
public static HTTPRequest Download(string url, string savePath, Action OnComplete, Action<long, long> OnProgress = null, Action<string> OnError = null)
|
||||
{
|
||||
Debug.Log($"Download {url}");
|
||||
ULog.Debug($"Download {url}");
|
||||
if (File.Exists(savePath))
|
||||
{
|
||||
OnComplete.Invoke();
|
||||
@@ -495,12 +495,12 @@ namespace UVC.Network
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Server error({resp.StatusCode} - {resp.Message})! " + new Exception(resp.Message));
|
||||
ULog.Debug($"Server error({resp.StatusCode} - {resp.Message})! " + new Exception(resp.Message));
|
||||
OnError?.Invoke($"Server error({resp.StatusCode} - {resp.Message})!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.Log(req.State.ToString() + ", " + new Exception(resp.Message));
|
||||
ULog.Debug(req.State.ToString() + ", " + new Exception(resp.Message));
|
||||
OnError?.Invoke(req.State.ToString());
|
||||
break;
|
||||
}
|
||||
@@ -510,17 +510,17 @@ namespace UVC.Network
|
||||
|
||||
request.DownloadSettings.OnDownloadStarted += async (HTTPRequest req, HTTPResponse resp, DownloadContentStream stream) =>
|
||||
{
|
||||
Debug.Log("Download Started");
|
||||
ULog.Debug("Download Started");
|
||||
|
||||
long len = await UniTask.RunOnThreadPool<long>(() => ConsumeDownloadStream(savePath, stream as BlockingDownloadContentStream));
|
||||
if (len == 0)
|
||||
OnError?.Invoke($"Download Fail!");
|
||||
|
||||
Debug.Log($"Download finished!");
|
||||
ULog.Debug($"Download finished!");
|
||||
};
|
||||
request.DownloadSettings.OnDownloadProgress += (HTTPRequest req, long progress, long length) =>
|
||||
{
|
||||
Debug.Log($"Download Progress! progress:{progress} length:{length}");
|
||||
ULog.Debug($"Download Progress! progress:{progress} length:{length}");
|
||||
OnProgress?.Invoke(progress, length);
|
||||
};
|
||||
request.DownloadSettings.DownloadStreamFactory = (req, resp, bufferAvailableHandler)
|
||||
@@ -553,14 +553,14 @@ namespace UVC.Network
|
||||
{
|
||||
try
|
||||
{
|
||||
//Debug.Log($"ConsumeDownloadStream blockingStream:{blockingStream == null}");
|
||||
//ULog.Debug($"ConsumeDownloadStream blockingStream:{blockingStream == null}");
|
||||
while (blockingStream != null && !blockingStream.IsCompleted)
|
||||
{
|
||||
if (blockingStream.TryTake(out var buffer))
|
||||
{
|
||||
try
|
||||
{
|
||||
//Debug.Log($"ConsumeDownloadStream buffer.Data:{buffer.Data.Length}, Offset:{buffer.Offset}, Count:{buffer.Count}");
|
||||
//ULog.Debug($"ConsumeDownloadStream buffer.Data:{buffer.Data.Length}, Offset:{buffer.Offset}, Count:{buffer.Count}");
|
||||
fs.Write(buffer.Data, buffer.Offset, buffer.Count);
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace UVC.network
|
||||
/// </remarks>
|
||||
private void CreateMQTTClient()
|
||||
{
|
||||
Debug.Log($"MQTT Domain:{MQTTDomain} , MQTTPORT:{MQTTPort}");
|
||||
ULog.Debug($"MQTT Domain:{MQTTDomain} , MQTTPORT:{MQTTPort}");
|
||||
var options = new ConnectionOptionsBuilder()
|
||||
.WithTCP(MQTTDomain, MQTTPort)
|
||||
.Build();
|
||||
@@ -252,7 +252,7 @@ namespace UVC.network
|
||||
/// </remarks>
|
||||
private void OnConnectedMQTT(MQTTClient client)
|
||||
{
|
||||
Debug.Log($"MQTT OnConnected");
|
||||
ULog.Debug($"MQTT OnConnected");
|
||||
BulkSubscribePacketBuilder builder = client.CreateBulkSubscriptionBuilder();
|
||||
foreach (var topic in topicHandler.Keys)
|
||||
{
|
||||
@@ -269,7 +269,7 @@ namespace UVC.network
|
||||
/// <param name="newState">새 상태</param>
|
||||
private void OnStateChangedMQTT(MQTTClient client, ClientStates oldState, ClientStates newState)
|
||||
{
|
||||
Debug.Log($"MQTT OnStateChanged {oldState} => {newState}");
|
||||
ULog.Debug($"MQTT OnStateChanged {oldState} => {newState}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -284,7 +284,7 @@ namespace UVC.network
|
||||
private void OnDisconnectedMQTT(MQTTClient client, DisconnectReasonCodes code, string reason)
|
||||
{
|
||||
//ULog.Info($"MQTT Disconnected - code: {code}, reason: '{reason}'");
|
||||
Debug.Log($"MQTTDisconnected pcTime={DateTime.Now}");
|
||||
ULog.Debug($"MQTTDisconnected pcTime={DateTime.Now}");
|
||||
// 지연 후에만 한 번 연결
|
||||
if (Application.isPlaying && autoReconnect)
|
||||
{
|
||||
@@ -305,7 +305,7 @@ namespace UVC.network
|
||||
/// </remarks>
|
||||
private void OnErrorMQTT(MQTTClient client, string reason)
|
||||
{
|
||||
Debug.LogError($"MQTT OnError reason: '{reason}'");
|
||||
ULog.Error($"MQTT OnError reason: '{reason}'", new Exception(reason));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -321,7 +321,7 @@ namespace UVC.network
|
||||
private void OnTopic(MQTTClient client, SubscriptionTopic topic, string topicName, ApplicationMessage message)
|
||||
{
|
||||
string payload = Encoding.UTF8.GetString(message.Payload.Data, message.Payload.Offset, message.Payload.Count);
|
||||
Debug.Log($"MQTT OnTopic {topic.Filter.OriginalFilter} => {payload}");
|
||||
ULog.Debug($"MQTT OnTopic {topic.Filter.OriginalFilter} => {payload}");
|
||||
ServerLog.LogMqtt(MQTTDomain, MQTTPort.ToString(), topic.Filter.OriginalFilter, payload, DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"));
|
||||
|
||||
if(topicHandler.TryGetValue(topic.Filter.OriginalFilter, out var handler))
|
||||
@@ -357,7 +357,7 @@ namespace UVC.network
|
||||
{
|
||||
if (client == null || client.State != ClientStates.Connected)
|
||||
{
|
||||
Debug.LogError("MQTT client is not connected. Cannot publish message.");
|
||||
ULog.Error("MQTT client is not connected. Cannot publish message.", new Exception("MQTT client is not connected. Cannot publish message."));
|
||||
return;
|
||||
}
|
||||
client.CreateApplicationMessageBuilder(topic)
|
||||
|
||||
Reference in New Issue
Block a user