bool TextRead() { lock (Client) { try { int Available = Client.Available; if (Available == 0) { return(false); } int NrToGet = IsConnectedViaTLS ? ReceiveBuffer.Length : Available; NrToGet = Math.Min(NrToGet, ReceiveBuffer.Length); int NrGot = 0; do { NrGot = ActiveStream.Read(ReceiveBuffer, 0, NrToGet); if (NrGot < 1) { break; } TotalDataReceivedInTextMode.Add(NrGot); lock (IncomingData) { try { string NewData = Encoding.UTF8.GetString(ReceiveBuffer, 0, NrGot); IncomingData += NewData; Log(4, "Adding incommingdata: {0}", NewData); } catch (System.Exception ex) { Console.WriteLine("EXCEPTION: " + ex.ToString()); } } } while (NrGot == NrToGet && IsConnectedViaTLS); if (OnData != null) { OnData.Invoke(); } return(true); //NewEvents.Enqueue(new Events(Events.EventType.GotData)); } catch (Exception e) { Log(1, "OnDisconnect in TextRead: {0}", e.ToString()); if (OnDisconnect == null) { OnDisconnect.Invoke(); } return(false); } } }
private void OnDataLoaded() { TEDDebug.LogFormat("[WebRequest] OnDataLoaded - requst id = {0}, url = {1}, data = {2}", m_requestId, m_request.url, DownloadHandlerBuffer.GetContent(m_request)); if (null == m_onDataCallback) { return; } m_onDataCallback.Invoke(m_requestId, DownloadHandlerBuffer.GetContent(m_request), m_userData); }