Files
servuo-plugins/overlay/Scripts/Scripts.csproj
Claude 7c9ce9741a Phase 1: loopback transport to the sidecar
BridgeLink owns a TcpClient to 127.0.0.1 and nothing else touches it. Emit() is
called from the Core thread; it enqueues onto a bounded drop-oldest queue and
returns. A link thread drains the queue and reconnects with backoff; a reader
thread parses inbound lines and marshals each to the Core thread via
Timer.DelayCall. An absent, slow, or wedged sidecar therefore cannot stall the
shard, which is the property the rest of the bridge depends on.

Outbound JSON is written by hand into a StringBuilder because it runs on the
Core thread for every event and the measured budget assumes that cost. Inbound
uses JavaScriptSerializer: commands arrive at human rates, so correctness beats
speed, and parsing happens off the Core thread anyway. That needs a
System.Web.Extensions reference.

server.hello is emitted per connection rather than once at ServerStarted. A
sidecar that restarts independently would otherwise never learn which shard it
is attached to. It carries a bootId, stable across reconnects and fresh on every
shard restart, so the sidecar can tell "I reconnected" from "the shard
restarted" and keep or discard its cache accordingly.

Two defects found by testing and fixed before commit:

  - Backoff ceiling was 30s, so a sidecar restart cost up to half a minute of
    buffering on a loopback socket. Now 5s.
  - A stale reader could kill a fresh connection: reader.Join(1s) can time out,
    and the old thread's finally block then set the shared _dead flag, possibly
    tearing down the connection that had replaced it. Connections now carry an
    epoch and a reader only marks dead the one it owned.

Acceptance evidence recorded in docs/PLAN.md §11: boots with no sidecar, buffers
through the outage and drains on connect, round-trips ping/pong on the Core
thread, survives unknown kinds and malformed JSON, and reconnects unattended.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 05:03:03 -05:00

44 lines
1.9 KiB
XML

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>Scripts</AssemblyName>
<RootNamespace>Server</RootNamespace>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<UseVSHostingProcess>False</UseVSHostingProcess>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<UseWindowsForms>false</UseWindowsForms>
<Platforms>x64</Platforms>
</PropertyGroup>
<!--
Conditioned on Configuration alone, not Configuration|Platform. ScriptCompiler.Compile
runs `dotnet build Scripts/Scripts.csproj -c Release` with no Platform, so Platform
defaults to AnyCPU. Under the old Platform-qualified conditions that meant OutputPath
was unset (the DLL landed in Scripts/bin/Release/ while the core loads Scripts.dll from
the base directory) and DefineConstants were empty (XmlSpawner compiled its non-ServUO
branches). The net effect was that runtime script compilation silently had no effect.
-->
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>..\</OutputPath>
<DefineConstants>TRACE;DEBUG;NEWTIMERS;ServUO</DefineConstants>
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>..\</OutputPath>
<DefineConstants>TRACE;NEWTIMERS;ServUO</DefineConstants>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Web" />
<!-- JavaScriptSerializer, for parsing inbound sidecar commands. See BridgeJson. -->
<Reference Include="System.Web.Extensions" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\Ultima\Ultima.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>