CoopRelay.Shared.Protocol 0.1.0

dotnet add package CoopRelay.Shared.Protocol --version 0.1.0
                    
NuGet\Install-Package CoopRelay.Shared.Protocol -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoopRelay.Shared.Protocol" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoopRelay.Shared.Protocol" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CoopRelay.Shared.Protocol" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoopRelay.Shared.Protocol --version 0.1.0
                    
#r "nuget: CoopRelay.Shared.Protocol, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoopRelay.Shared.Protocol@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoopRelay.Shared.Protocol&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CoopRelay.Shared.Protocol&version=0.1.0
                    
Install as a Cake Tool

CoopRelay

CoopRelay 是一个可复用的联机框架:让任何基于 LiteNetLib 的游戏 Mod 无需 NAT 打洞即可获得广域网(WAN) 联机能力——通过一个轻量 UDP 中继枢纽转发流量。它从《逃离鸭科夫》联机 Mod 中抽离并通用化,其他 Mod 可在 几分钟内接入。

程序包

目标框架 职责
CoopRelay.Shared.Protocol netstandard2.1 线缆协议常量(UDP 中继 OpCode、虚拟 IP 前缀、默认端口),客户端与服务端共享。
CoopRelay.Client netstandard2.1 客户端 SDK。用 Harmony 挂钩 Socket,使 LiteNetLib 流量经中继枢纽转发。可直接接入任意 BepInEx Mod。
CoopRelay.Server.Core net8.0 纯 UDP 中继引擎(RelayServer + IRelayRoomRegistry),自行实现房间/会话存储即可。
CoopRelay.Launcher.Core net8.0 与 UI 无关的启动器构件:BepInEx + Mod 部署、启动配置写入、游戏进程监控。

此外 CoopRelay.Server.Host 是开箱即用的中继服务器可执行程序(内存房间注册表),以 GitHub Release 二进制 / Docker 镜像形式分发,而非 NuGet 库。

安装

4 个库包同时发布在 nuget.org(公开)与 GitHub Packages(私有)。从 nuget.org 安装:

dotnet add package CoopRelay.Client          # 客户端 SDK(mod 接入)
dotnet add package CoopRelay.Server.Core     # 中继服务端引擎(自建 host)
dotnet add package CoopRelay.Launcher.Core   # 启动器构件
# CoopRelay.Shared.Protocol 会作为上面各包的依赖自动引入

通用中继服务器 CoopRelay.Server.Host(自包含单文件,无需安装 .NET 运行时)请从 Releases 下载 linux-x64 / win-x64 压缩包。

快速开始

端到端 5 分钟演练见 docs/coop-relay-quickstart.md(使用 samples/ 下的示例工程: SampleCoopMod + SampleGame + SampleLauncher)。

客户端接入仅三步:

// 1) 注入 LiteNetLib 回调,让 SDK 接管底层 Socket
CoopRelayClient.Bootstrap(hooks);

// 2) 读取启动器写入的 coopmod_launch.config
var args = LauncherArgs.Parse();

// 3) 启动器要求自动连接时:先 Configure(在你的网络栈启动前确定身份),再 ConnectToRelay
if (args.AutoConnectRequested)
{
    CoopRelayClient.Configure(config);   // 必须在 MyNet.StartNetwork() 之前
    MyNet.StartNetwork(isHost);
    CoopRelayClient.ConnectToRelay(config);
}

⚠️ 顺序约定:若你的网络栈在启动时会快照 PlayerId / PlayerName,务必先 Configure(config) 再启动网络栈, 否则会抓到默认随机身份。详见 客户端 SDK 文档

文档

从源码构建

dotnet build CoopRelay.sln -c Release

客户端 SDK 与示例工程编译时依赖 Unity / BepInEx / LiteNetLib / Harmony 程序集,这些都捆绑在 libs/ 中,因此整个解决方案可在 CI 与贡献者机器上构建,无需本地安装游戏。来源与许可说明见 libs/README.md

许可

本框架代码采用 MIT。注意:libs/ 下捆绑的第三方程序集保留各自许可,不在本许可覆盖范围内,详见 libs/README.md

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on CoopRelay.Shared.Protocol:

Package Downloads
CoopRelay.Client

CoopRelay framework: client SDK that bridges LiteNetLib traffic through a CoopRelay UDP hub via Harmony Socket patches. Drop into any BepInEx mod to gain WAN coop without NAT punching.

CoopRelay.Launcher.Core

CoopRelay framework: UI-agnostic launcher building blocks. Drop into any WPF/Avalonia/CLI launcher to gain one-click BepInEx + Mod deployment, launch config file generation, and game-process lifecycle monitoring for CoopRelay-based coop mods.

CoopRelay.Server.Core

CoopRelay framework: pure UDP relay engine (RelayServer + IRelayRoomRegistry). Plug in your own room/session store to expose WAN coop for any LiteNetLib-based game.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 48 6/8/2026