public static SocketMessager Parse(byte[] data) { if (data == null) { return(new SocketMessager("NULL")); } if (data.Length == 1 && data[0] == 0) { return(SocketMessager.SYS_TEST_LINK); } int idx = BaseSocket.findBytes(data, new byte[] { 13, 10 }, 0); string text = Encoding.UTF8.GetString(data, 0, idx); string[] loc1 = text.Split(new string[] { "\t" }, 4, StringSplitOptions.None); string loc2 = loc1[0]; string loc3 = loc1.Length > 1 ? loc1[1].Replace("\\\\", "\\").Replace("\\t", "\t").Replace("\\n", "\r\n") : null; string loc4 = loc1.Length > 2 ? loc1[2].Replace("\\\\", "\\").Replace("\\t", "\t").Replace("\\n", "\r\n") : null; string loc5 = loc1.Length > 3 ? loc1[3] : null; SocketMessager messager; using (MemoryStream ms = new MemoryStream()) { ms.Write(data, idx + 2, data.Length - idx - 2); messager = new SocketMessager(loc3, loc4, ms.Length > 0 ? BaseSocket.Deserialize(ms.ToArray()) : null); //using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress)) { // using (MemoryStream msOut = new MemoryStream()) { // ds.CopyTo(msOut); // messager = new SocketMessager(loc3, loc4, ms.Length > 0 ? BaseSocket.Deserialize(ms.ToArray()) : null); // } //} } if (int.TryParse(loc2, out idx)) { messager._id = idx; } if (!string.IsNullOrEmpty(loc5)) { DateTime.TryParse(loc5, out messager._remoteTime); } if (messager._arg is Exception) { messager._exception = messager._arg as Exception; } return(messager); }