public void Listen(int port, HttpDispatcher http) { // websocket handling http.WebSocketOpened .Subscribe(ws => { AddSession(ws); ws.Closed += () => { RemoveSession(ws); }; }); // listen http m_disposable = ListenObservable.Listen(port).Subscribe(x => { http.Process(x, new byte[1024]); }, ex => { if (ex is ObjectDisposedException) { } else { Logging.Exception(ex); } }) ; }
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); } }); }