/// <summary> /// Serializes the object into protobuf byte data /// </summary> public static byte[] SerializeUpdate(IServerUpdate update) { MemoryStream ms = new MemoryStream(); update.Serialize(ms); return(ms.GetBuffer()); }
/// <summary> /// Serializes and sends a status update to the client /// </summary> /// <param name="update"></param> public void SendStatusUpdate(IServerUpdate update) { try { byte[] updateData = Util.SerializeUpdate(update); _socket.BeginSend(updateData, 0, updateData.Length, SocketFlags.None, null, null); } catch (SocketException ex) { Console.WriteLine("Error " + ex.Message); } }
public static void UnregisterObject(IServerUpdate obj) { _instance.serverTicked.Remove(obj); }
public static void RegisterObject(IServerUpdate obj) { _instance.serverTicked.Add(obj); }