Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b3ed63b
Start of custom hosts
Nytra Oct 4, 2025
15f68bf
Custom queues work
Nytra Oct 5, 2025
d4641ca
Small changes to logging
Nytra Oct 5, 2025
d287b26
give each backend a unique type manager
Nytra Oct 5, 2025
3648baa
Optimize and fix some stuff
Nytra Oct 5, 2025
23e605c
A lot of changes
Nytra Oct 7, 2025
adf88d4
Move pool borrow and return to TypeManager
Nytra Oct 8, 2025
46057e4
Add default memory pools and other stuff
Nytra Oct 10, 2025
dd36840
Copy lib DLLs to the correct folder and fix Thunderstore package fold…
Nytra Oct 28, 2025
72f9443
Merge branch 'main' into customHosts
Nytra Oct 28, 2025
ece1ea6
Push latest
Nytra Nov 4, 2025
9f82b06
Fix lib target dir for BepInEx tests
Nytra Nov 4, 2025
c64dfae
Pushing latest, untested
Nytra Nov 5, 2025
6797874
Push latest stuff
Nytra Nov 6, 2025
c130fe5
Improvements and add a way to get a fallback messaging system
Nytra Nov 8, 2025
b8a3d03
Added a way to check the latency of the connection
Nytra Nov 8, 2025
ed3a03d
Improvements to the ping command
Nytra Nov 8, 2025
7679a6c
Merge branch 'main' into customHosts
Nytra Nov 9, 2025
ce6210c
Fixes for linux headless
Nytra Nov 9, 2025
c0702a5
Catch task cancelled exception
Nytra Nov 11, 2025
825348d
Attempts to fix the order of init steps (not fully done)
Nytra Nov 23, 2025
d9d34c5
Fixed order of init steps hopefully
Nytra Nov 24, 2025
2a97db2
.NET 10
Nytra Nov 25, 2025
e5240c4
Turn off ping command handling due to infinite loop bug
Nytra Nov 28, 2025
7d54fc2
Fix ping command and comment out type command handling for now
Nytra Dec 12, 2025
8b14925
Fix indentation in csproj files
Nytra Dec 12, 2025
feac617
Cleanup and add StringArray and StringHashSet commands
Nytra Dec 19, 2025
b8c58bc
Improvements to nullability of types
Nytra Dec 19, 2025
393f965
Improve nullable-awareness and add StringCollectionCommand (replaces …
Nytra Dec 20, 2025
fc61e3b
On demand type registration
Nytra Dec 20, 2025
c8f32c0
Fix identifiable type command not working
Nytra Dec 20, 2025
3cad3fd
Speed up init process and have both sides use the ready command
Nytra Dec 20, 2025
d760991
Some small adjustments/improvements
Nytra Dec 21, 2025
41e5419
Further improvements, make Messenger disposable, introduce new Standa…
Nytra Dec 22, 2025
0a9dbbf
Switch to generic send collection commands in Messenger, and migrate …
Nytra Dec 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Extensions/BepInExShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ public static class BepInExExtensions

public static void SyncConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
{
messenger.ReceiveConfigEntry<T>(configEntry);
_syncStates[configEntry] = true;
if (Messenger.IsAuthority)
if (messenger.IsAuthority == true)
messenger.SendConfigEntry<T>(configEntry);
configEntry.SettingChanged += (sender, args) =>
{
if (_syncStates.TryGetValue(configEntry, out bool value) && value == true)
messenger.SendConfigEntry<T>(configEntry);
};
messenger.ReceiveConfigEntry<T>(configEntry);
}

public static void SyncConfigEntry(this Messenger messenger, ConfigEntry<string> configEntry)
{
messenger.ReceiveConfigEntry(configEntry);
_syncStates[configEntry] = true;
if (Messenger.IsAuthority)
if (messenger.IsAuthority == true)
messenger.SendConfigEntry(configEntry);
configEntry.SettingChanged += (sender, args) =>
{
if (_syncStates.TryGetValue(configEntry, out bool value) && value == true)
messenger.SendConfigEntry(configEntry);
};
messenger.ReceiveConfigEntry(configEntry);
}

public static void SendConfigEntry<T>(this Messenger messenger, ConfigEntry<T> configEntry) where T : unmanaged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Version>1.0.0</Version>
<Authors>Nytra</Authors>
<TargetFramework>net472</TargetFramework>
<LangVersion>12</LangVersion>
<LangVersion>12</LangVersion>
<RepositoryUrl>https://github.com/Nytra/ResoniteInterprocessLib</RepositoryUrl>
<PackageId>Nytra.InterprocessLib.BepInEx_Extensions</PackageId>
<Product>InterprocessLib.BepInEx_Extensions</Product>
Expand All @@ -16,13 +16,13 @@
<GamePath Condition="'$(ResonitePath)' != ''">$(ResonitePath)/</GamePath>
<GamePath Condition="Exists('$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\')">$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</GamePath>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/')">$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/</GamePath>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/')">$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/</GamePath>
<Configurations>Debug;Release;Tests</Configurations>
</PropertyGroup>

<ItemGroup>
<Reference Include="0Harmony">
<Reference Include="0Harmony">
<HintPath>$(GamePath)Renderer\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
Expand All @@ -34,7 +34,7 @@
<Reference Include="Renderite.Unity">
<HintPath>$(GamePath)Renderer\Renderite.Renderer_Data\Managed\Renderite.Unity.dll</HintPath>
</Reference>
<Reference Include="Renderite.Shared">
<Reference Include="Renderite.Shared">
<HintPath>$(GamePath)Renderer\Renderite.Renderer_Data\Managed\Renderite.Shared.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
Expand All @@ -43,15 +43,15 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(GamePath)Renderer\Renderite.Renderer_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Compile Include="../BepInExShared.cs" />
<Compile Include="../BepInExShared.cs" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<ItemGroup>
<PluginFiles Include="$(TargetPath)" />
</ItemGroup>

<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\..\out\" />
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\..\out\" />
<Message Text="Copied plugin files to out dir" Importance="high" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<Version>1.0.0</Version>
<Authors>Nytra</Authors>
<TargetFramework>net9.0</TargetFramework>
<Langversion>13</Langversion>
<TargetFramework>net10.0</TargetFramework>
<Langversion>14</Langversion>
<RepositoryUrl>https://github.com/Nytra/ResoniteInterprocessLib</RepositoryUrl>
<PackageId>Nytra.InterprocessLib.BepisLoader_Extensions</PackageId>
<Product>InterprocessLib.BepisLoader_Extensions</Product>
Expand All @@ -16,7 +16,8 @@
<GamePath Condition="'$(ResonitePath)' != ''">$(ResonitePath)/</GamePath>
<GamePath Condition="Exists('$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\')">$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</GamePath>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/')">$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/</GamePath>
<RestoreAdditionalProjectSources>
https://nuget-modding.resonite.net/v3/index.json;
</RestoreAdditionalProjectSources>
Expand Down Expand Up @@ -49,7 +50,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="../BepInExShared.cs" />
<Compile Include="../BepInExShared.cs" />
</ItemGroup>

<ItemGroup>
Expand All @@ -62,8 +63,8 @@
<ItemGroup>
<PluginFiles Include="$(TargetPath)" />
</ItemGroup>
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\..\out\" />
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\..\out\" />
<Message Text="Copied files to out dir" Importance="high" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<Version>1.0.0</Version>
<Authors>Nytra</Authors>
<TargetFramework>net9.0</TargetFramework>
<Langversion>13</Langversion>
<TargetFramework>net10.0</TargetFramework>
<Langversion>14</Langversion>
<RepositoryUrl>https://github.com/Nytra/ResoniteInterprocessLib</RepositoryUrl>
<PackageId>Nytra.InterprocessLib.RML_Extensions</PackageId>
<Product>InterprocessLib.RML_Extensions</Product>
Expand All @@ -17,8 +17,9 @@
<GamePath Condition="'$(ResonitePath)' != ''">$(ResonitePath)/</GamePath>
<GamePath Condition="Exists('$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\')">$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</GamePath>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<Configurations>Debug;Release;Tests</Configurations>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/')">$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/</GamePath>
<Configurations>Debug;Release;Tests</Configurations>
</PropertyGroup>

<ItemGroup Condition="!Exists('$(GamePath)')">
Expand All @@ -39,7 +40,7 @@
<HintPath>$(GamePath)Renderite.Shared.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ResoniteModLoader">
<Reference Include="ResoniteModLoader">
<HintPath>$(GamePath)Libraries/ResoniteModLoader.dll</HintPath>
<Private>False</Private>
</Reference>
Expand All @@ -55,8 +56,8 @@
<ItemGroup>
<PluginFiles Include="$(TargetPath)" />
</ItemGroup>
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\..\out\" />
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\..\out\" />
<Message Text="Copied files to out dir" Importance="high" />

<Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(GamePath)rml_libs" Condition="'$(CopyToPlugins)' == 'true'" />
Expand Down
8 changes: 4 additions & 4 deletions Extensions/InterprocessLib.RML_Extensions/RML_Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ public static class RML_Extensions

public static void SyncConfigEntry<T>(this Messenger messenger, ModConfigurationKey<T> configEntry) where T : unmanaged
{
messenger.ReceiveConfigEntry<T>(configEntry);
_syncStates[configEntry] = true;
if (Messenger.IsAuthority)
if (messenger.IsAuthority == true)
messenger.SendConfigEntry<T>(configEntry);
configEntry.OnChanged += (object? newValue) =>
{
if (_syncStates.TryGetValue(configEntry, out bool value) && value == true)
messenger.SendConfigEntry<T>(configEntry);
};
messenger.ReceiveConfigEntry<T>(configEntry);
}

public static void SyncConfigEntry(this Messenger messenger, ModConfigurationKey<string> configEntry)
{
messenger.ReceiveConfigEntry(configEntry);
_syncStates[configEntry] = true;
if (Messenger.IsAuthority)
if (messenger.IsAuthority == true)
messenger.SendConfigEntry(configEntry);
configEntry.OnChanged += (object? newValue) =>
{
if (_syncStates.TryGetValue(configEntry, out bool value) && value == true)
messenger.SendConfigEntry(configEntry);
};
messenger.ReceiveConfigEntry(configEntry);
}

public static void SendConfigEntry<T>(this Messenger messenger, ModConfigurationKey<T> configEntry) where T : unmanaged
Expand Down
98 changes: 66 additions & 32 deletions InterprocessLib.FrooxEngine/FrooxEngineInit.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,88 @@
using Elements.Core;
using FrooxEngine;
using Renderite.Shared;
using System.Reflection;

namespace InterprocessLib;

internal static class FrooxEngineInit
internal class FrooxEnginePool : IMemoryPackerEntityPool
{
private static void CommandHandler(RendererCommand command, int messageSize)
public static readonly FrooxEnginePool Instance = new();

T IMemoryPackerEntityPool.Borrow<T>()
{
return Pool<T>.Borrow();
}

void IMemoryPackerEntityPool.Return<T>(T value)
{
Pool<T>.ReturnCleaned(ref value);
}
}

internal static class FrooxEngineInit
{
public static void Init()
{
if (Messenger.Host is not null)
throw new InvalidOperationException("Messenger has already been initialized!");
if (Messenger.DefaultInitStarted)
throw new InvalidOperationException("Messenger default backend initialization has already been started!");

Messenger.DefaultInitStarted = true;

Task.Run(InitLoop);
InnerInit();
}
private static async void InitLoop()
private static void InnerInit()
{
if (Engine.Current?.RenderSystem?.Engine is null)
var args = Environment.GetCommandLineArgs();
string? queueName = null;
for (int i = 0; i < args.Length; i++)
{
await Task.Delay(1);
InitLoop();
if (args[i].Equals("-shmprefix", StringComparison.InvariantCultureIgnoreCase))
{
queueName = args[i + 1];
break;
}
}
else

Messenger.OnWarning = (msg) =>
{
UniLog.Warning($"[InterprocessLib] [WARN] {msg}");
};
Messenger.OnFailure = (ex) =>
{
UniLog.Error($"[InterprocessLib] [ERROR] Error in InterprocessLib Messaging Backend!\n{ex}");
};
#if DEBUG
Messenger.OnDebug = (msg) =>
{
await Task.Delay(100);
UniLog.Log($"[InterprocessLib] [DEBUG] {msg}");
};
#endif

var renderSystemMessagingHost = (RenderiteMessagingHost?)typeof(RenderSystem).GetField("_messagingHost", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(Engine.Current!.RenderSystem);
if (renderSystemMessagingHost is null)
throw new InvalidOperationException("Engine is not configured to use a renderer!");
MessagingSystem? system = null;

Messenger.OnWarning = (msg) =>
{
UniLog.Warning($"[InterprocessLib] [WARN] {msg}");
};
Messenger.OnFailure = (ex) =>
{
UniLog.Error($"[InterprocessLib] [ERROR] Error in InterprocessLib Messaging Host!\n{ex}");
};
#if DEBUG
Messenger.OnDebug = (msg) =>
if (queueName is null)
{
Messenger.OnDebug?.Invoke("Shared memory queue name is null! Attempting to use fallback...");
var task = Messenger.GetFallbackSystem("Resonite", true, MessagingManager.DEFAULT_CAPACITY, FrooxEnginePool.Instance, null, Messenger.OnFailure, Messenger.OnWarning, Messenger.OnDebug);
task.Wait();
system = task.Result;
if (system is null)
{
UniLog.Log($"[InterprocessLib] [DEBUG] {msg}");
};
#endif
Messenger.IsAuthority = true;
Messenger.Host = new MessagingHost(Messenger.IsAuthority, renderSystemMessagingHost!.QueueName, renderSystemMessagingHost.QueueCapacity, renderSystemMessagingHost, CommandHandler, Messenger.OnFailure, Messenger.OnWarning, Messenger.OnDebug);
Messenger.FinishInitialization();
throw new EntryPointNotFoundException("Unable to get fallback messaging system!");
}
}
else
{
system = new MessagingSystem(true, $"InterprocessLib-{queueName}", MessagingManager.DEFAULT_CAPACITY, FrooxEnginePool.Instance, null, Messenger.OnFailure, Messenger.OnWarning, Messenger.OnDebug);
system.Connect();
}

lock (Messenger.LockObj)
{
Messenger.PreInit(system);
Messenger.SetDefaultSystem(system);
system.Initialize();
}

//Engine.Current.OnShutdown += system.Dispose;
}
}
22 changes: 12 additions & 10 deletions InterprocessLib.FrooxEngine/InterprocessLib.FrooxEngine.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.0.1</Version>
<Version>3.0.0</Version>
<Authors>Nytra</Authors>
<TargetFramework>net9.0</TargetFramework>
<Langversion>13</Langversion>
<TargetFramework>net10.0</TargetFramework>
<Langversion>14</Langversion>
<RepositoryUrl>https://github.com/Nytra/ResoniteInterprocessLib</RepositoryUrl>
<PackageId>Nytra.InterprocessLib.FrooxEngine</PackageId>
<Product>InterprocessLib.FrooxEngine</Product>
<RootNamespace>InterprocessLib</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<Deterministic>true</Deterministic>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<GamePath Condition="'$(ResonitePath)' != ''">$(ResonitePath)/</GamePath>
<GamePath Condition="Exists('$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\')">$(MSBuildProgramFiles32)\Steam\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/.steam/steam/steamapps/common/Resonite/')">$(HOME)/.steam/steam/steamapps/common/Resonite/</GamePath>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<Configurations>Debug;Release;Tests</Configurations>
<GamePath Condition="Exists('G:\SteamLibrary\steamapps\common\Resonite\')">G:\SteamLibrary\steamapps\common\Resonite\</GamePath>
<GamePath Condition="Exists('$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/')">$(HOME)/snap/steam/common/.local/share/Steam/steamapps/common/Resonite/</GamePath>
<Configurations>Debug;Release;Tests</Configurations>
</PropertyGroup>

<ItemGroup Condition="!Exists('$(GamePath)')">
Expand All @@ -30,26 +32,26 @@
<HintPath>$(GamePath)Renderite.Shared.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FrooxEngine">
<Reference Include="FrooxEngine">
<HintPath>$(GamePath)FrooxEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Elements.Core">
<Reference Include="Elements.Core">
<HintPath>$(GamePath)Elements.Core.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

<ItemGroup>
<Compile Include="../InterprocessLib.Shared/*.cs" />
<Compile Include="../InterprocessLib.Shared/*.cs" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<ItemGroup>
<PluginFiles Include="$(TargetPath)" />
</ItemGroup>
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\out\" />
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="..\out\" />
<Message Text="Copied files to out dir" Importance="high" />
</Target>
</Project>
Loading