using System;
using Unity.MLAgents.SideChannels;
using UnityEngine;

namespace Statistics
{
    public class LoggerSideChannel : SideChannel
    {
        public LoggerSideChannel()
        {
            ChannelId = new Guid("621f0a70-4f87-11ea-a6bf-784f4387d1f7");
        }

        public void SendLog(Log log)
        {
            using (var logOut = new OutgoingMessage())
            {
                logOut.WriteString(JsonUtility.ToJson(log));
                QueueMessageToSend(logOut);
            }
        }

        protected override void OnMessageReceived(IncomingMessage msg)
        {
            var receivedString = msg.ReadString();
            Debug.Log("From Python : " + receivedString);
        }
    }
}