Пример #1
0
 public byte[] Write <T>(T packet) where T : class, new()
 {
     _netDataWriter.Reset();
     WriteHash <T>(_netDataWriter);
     _netSerializer.Serialize(_netDataWriter, packet);
     return(_netDataWriter.CopyData());
 }
Пример #2
0
        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());
        }
Пример #3
0
 /// <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());
 }