A cross-platform Minecraft P2P online multi-player library in C#, developed using high-performance sockets for excellent forwarding performance, with P2P powered by the Zerotier SDK.
Proudly powered by another of our open-source projects: Hive.Framework
| Function | Status |
|---|---|
Server: Log Room Ops Info to local DB | ✅ |
Server: Client/Room management | ✅ |
Server: Relay Server management | ✅ |
Relay: Relay Server impl based on Hive | ✅ |
Relay: Ultra low latency relay impl | ✅ |
Client: ZT based P2P connection | ✅ |
Client: ZT based Relay connection | ✅ |
Client: ConnectX based Relay connection | ✅ |
| Dual Stack Socket Support | ✅ |
We are using the MSDI(Microsoft.Extensions.DependencyInjection) as our DI container. The best practice is to use .NET Generic Host for you program.
First, add the following method for the Server Config. ConnectXServerIp will be the Backend address for the ConnectX.Server.
privatestaticIClientSettingProviderGetConnectXSettings(){varserverIp=IPAddress.None;try{varips=Dns.GetHostAddresses(ConnectXServerIp);varipv4Addresses=ips.Where(ip =>ip.AddressFamily==AddressFamily.InterNetwork).Where(ip =>!ip.IsLocalIpAddress()).ToArray();if(ipv4Addresses.Length>0)serverIp=ipv4Addresses[0];}catch(Exceptionex){Log.Logger.Error(ex,"Failed to resolve ConnectX server IP.");}returnnewDefaultClientSettingProvider{ServerAddress=serverIp,ServerPort=ConnectXServerPort,JoinP2PNetwork=true};}Then, just add one more line to complete the setup!
private static void ConfigureServices(IServiceCollection services)
{
// ...
+ services.UseConnectX(GetConnectXSettings);
// ...
}Inject IServerLinkHolder and Client into the VM where you want to manage the room instances.
await_serverLinkHolder.ConnectAsync(CancellationToken.None);Important
Please make sure that before you perform any room operations, you need to make sure you already connected to the ConnectX server!
awaitTaskHelper.WaitUntilAsync(()=>_serverLinkHolderis{IsConnected:true,IsSignedIn:true});varmessage=newCreateGroup{UserId=_serverLinkHolder.UserId,RoomName=createRoomRecord.RoomName,RoomDescription=createRoomRecord.RoomDescription,RoomPassword=createRoomRecord.RoomPassword,IsPrivate=createRoomRecord.IsPrivateRoom,MaxUserCount=3};var(groupInfo,status,err)=await_multiPlayerClient.CreateGroupAsync(message,CancellationToken.None);if(groupInfo==null||status!=GroupCreationStatus.Succeeded||!string.IsNullOrEmpty(err)){// Error processreturn;}_multiPlayerClient.OnGroupStateChanged+=MultiPlayerClientOnGroupStateChanged;// Other actionsMIT. This means that you can modify or use our code for any purpose, however, copyright notice and permission notice shall be included in all copies or substantial portions of your software.
ConnectX is not affiliated with Mojang or any part of its software.
This project, ConnectX, is licensed under the MIT License.
ConnectX uses ZeroTier, which is licensed under the Apache License 2.0 as of 2025-01-01, following its license change from BSL 1.1. You can find more about ZeroTier's licensing at https://github.com/zerotier/ZeroTierOne.
Here, we'll list all programs using our code without obeying the MIT License.
