-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2557b6f
Showing
9 changed files
with
1,273 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.