public static Packet Deserialize(Session session, MemoryStream source, out object customErrorData) { customErrorData = null; var begin = source.Position; var buffer = new byte[4]; source.Read(buffer, 0, sizeof(int)); var id = ConvertHelper.GetInt32(buffer); var packet = ProtoHelper.GetPacket(id); packet.DeSerialize(source); return(packet); }