public bool SendCommand(IClientCommand o) { MemoryStream ms = new MemoryStream(); try { BinaryWriter writer = new BinaryWriter(ms); // write packet ID. currently a byte. NetworkPacketId[] npi = (NetworkPacketId[])o.GetType().GetCustomAttributes(typeof(NetworkPacketId), false); if (npi.Length != 0) { writer.Write(npi[0].PacketID); Serializer.Serialize(ms, o); return(SendPacket(ms.ToArray())); } Debug.LogFormat("ERROR: Can't send commands without ID! (type = {0})", o.GetType().Name); return(false); } catch (Exception) { return(false); } finally { ms.Close(); } }