Some changes to support mod reloading. (ModAPI messages are still not being recieved properly in nexus mod) this could be a serverside issue but unknown currently
This commit is contained in:
36
Utilities/NetUtils.cs
Normal file
36
Utilities/NetUtils.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using ProtoBuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SeamlessClient.Utilities
|
||||
{
|
||||
public class NetUtils
|
||||
{
|
||||
public static byte[] Serialize<T>(T instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return null;
|
||||
|
||||
using (var m = new MemoryStream())
|
||||
{
|
||||
Serializer.Serialize(m, instance);
|
||||
return m.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static T Deserialize<T>(byte[] data)
|
||||
{
|
||||
if (data == null)
|
||||
return default(T);
|
||||
|
||||
using (var m = new MemoryStream(data))
|
||||
{
|
||||
return Serializer.Deserialize<T>(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user