public byte[] Write <T>(T packet) where T : class, new() { _netDataWriter.Reset(); WriteHash <T>(_netDataWriter); _netSerializer.Serialize(_netDataWriter, packet); return(_netDataWriter.CopyData()); }
public byte[] Write <T>(T packet) where T : class, new() { #if DEBUG if (!typeof(T).IsDefined(typeof(HidePacketInDebugLogsAttribute), false)) { Logger.Log.Debug($"Packet Sent: {packet.GetType().Name}"); } #endif _netDataWriter.Reset(); WriteHash <T>(_netDataWriter); _netSerializer.Serialize(_netDataWriter, packet); return(_netDataWriter.CopyData()); }
/// <summary> /// Serialize object to byte array /// </summary> /// <param name="obj">Object to serialize</param> /// <returns>byte array with serialized data</returns> public byte[] Serialize <T>(T obj) where T : class, new() { if (_writer == null) { _writer = new NetDataWriter(); } _writer.Reset(); Serialize(_writer, obj); return(_writer.CopyData()); }