Пример #1
0
 private void OnDisable()
 {
     if (m_console != null)
     {
         m_console.Dispose();
         m_console = null;
     }
     if (m_disposable != null)
     {
         m_disposable.Dispose();
         m_disposable = null;
     }
 }
Пример #2
0
        private void OnEnable()
        {
            Logging.Info("listen " + m_port);
            var m_http = new HttpDispatcher(SetupHttpMount());

            m_console = new WSConsole();
            m_console.Listen(m_port, m_http);

            var utf8 = new System.Text.UTF8Encoding(false);

            m_disposable = Logging.Observable.Subscribe(x =>
            {
                try
                {
                    // LogEntry to Json
                    var json = UnityEngine.JsonUtility.ToJson(x);
                    m_console.SendFrame(WebSocketFrameOpCode.Text, new ArraySegment <byte>(utf8.GetBytes(json)));
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            });
        }