static void OnResponse(int nativeId, int httpStatus, IntPtr pBuffer, int length, int err) { WebGLConnection conn = null; if (!Connections.TryGetValue(nativeId, out conn)) { HTTPManager.Logger.Error("WebGLConnection - OnResponse", "No WebGL connection found for nativeId: " + nativeId.ToString()); return; } HTTPManager.Logger.Information("WebGLConnection - OnResponse", string.Format("{0} {1} {2} {3}", nativeId, httpStatus, length, err), conn.Context); BufferSegment payload = BufferSegment.Empty; if (length > 0) { var buffer = BufferPool.Get(length, true); XHR_CopyResponseTo(nativeId, buffer, length); payload = new BufferSegment(buffer, 0, length); } conn.OnResponse(httpStatus, payload); }
static void OnResponse(int nativeId, int httpStatus, IntPtr pBuffer, int length, int err) { WebGLConnection conn = null; if (!Connections.TryGetValue(nativeId, out conn)) { HTTPManager.Logger.Error("WebGLConnection - OnResponse", "No WebGL connection found for nativeId: " + nativeId.ToString()); return; } HTTPManager.Logger.Information("WebGLConnection - OnResponse", string.Format("{0} {1} {2} {3}", nativeId, httpStatus, length, err), conn.Context); byte[] buffer = BufferPool.NoData; if (length > 0) { buffer = BufferPool.Get(length, true); XHR_CopyResponseTo(nativeId, buffer, length); } conn.OnResponse(httpStatus, buffer, length); if (buffer != BufferPool.NoData) { BufferPool.Release(buffer); } }
static void OnResponse(int nativeId, int httpStatus, IntPtr pBuffer, int length, int err) { WebGLConnection conn = null; if (!Connections.TryGetValue(nativeId, out conn)) { HTTPManager.Logger.Error("WebGLConnection - OnResponse", "No WebGL connection found for nativeId: " + nativeId.ToString()); return; } HTTPManager.Logger.Information("WebGLConnection - OnResponse", string.Format("{0} {1} {2} {3}", nativeId, httpStatus, length, err), conn.Context); byte[] buffer = BufferPool.Get(length, true); // Copy data from the 'unmanaged' memory to managed memory. Buffer will be reclaimed by the GC. Marshal.Copy(pBuffer, buffer, 0, length); conn.OnResponse(httpStatus, buffer, length); BufferPool.Release(buffer); }