Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
djungelorm committed Mar 13, 2023
0 parents commit 2557b6f
Show file tree
Hide file tree
Showing 9 changed files with 1,273 additions and 0 deletions.
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions KRPC2.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33414.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KRPC2", "KRPC2\KRPC2.csproj", "{4E531B4F-A167-4362-8432-AE48440A3500}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E531B4F-A167-4362-8432-AE48440A3500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E531B4F-A167-4362-8432-AE48440A3500}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E531B4F-A167-4362-8432-AE48440A3500}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E531B4F-A167-4362-8432-AE48440A3500}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D9A3F7C9-BB32-4C76-AB1E-A711E350DA34}
EndGlobalSection
EndGlobal
45 changes: 45 additions & 0 deletions KRPC2/KRPC2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using SpaceWarp;
using SpaceWarp.API.Mods;
using BepInEx;
using KRPC;
using KRPC.Server;
using KRPC.Server.TCP;
using KRPC.Service;
using System.Net;

namespace KRPC2
{
[BepInPlugin("krpc", "krpc2", "0.1.0")]
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
public class KRPC2 : BaseSpaceWarpPlugin
{
private Core core;
public override void OnInitialized()
{
Logger.LogInfo("Scanning for services...");
KRPC.Service.Scanner.Scanner.GetServices();
Logger.LogInfo("Scanning complete");

Logger.LogInfo("Initializing core...");
core = Core.Instance;
CallContext.SetGameScene(GameScene.SpaceCenter);
core.OnClientRequestingConnection += (s, e) => e.Request.Allow();
Logger.LogInfo("Core initialized");

Logger.LogInfo("Starting server (rpc port 50000, stream port 50001");
var rpcTcpServer = new TCPServer(IPAddress.Any, 50000);
var streamTcpServer = new TCPServer(IPAddress.Any, 50001);
var rpcServer = new KRPC.Server.ProtocolBuffers.RPCServer(rpcTcpServer);
var streamServer = new KRPC.Server.ProtocolBuffers.StreamServer(streamTcpServer);
var server = new Server(Guid.NewGuid(), Protocol.ProtocolBuffersOverTCP, "KRPC2 Server", rpcServer, streamServer);
core.Add(server);
core.StartAll();
Logger.LogInfo("Server started");
}

public void Update()
{
core.Update();
}
}
}
Loading

0 comments on commit 2557b6f

Please sign in to comment.