Skip to content

Commit

Permalink
v1.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
QuillDev committed Jan 9, 2021
1 parent a69f069 commit 1654f50
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 56 deletions.
1 change: 1 addition & 0 deletions Core/Config/ConfigService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using NetJoy.Core.Utils;
using NetJoy.Core.Utils.General;
using Nett;

namespace NetJoy.Core.Config
Expand Down
4 changes: 1 addition & 3 deletions Core/NetJoy/Client/Handling/JoyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using Nefarius.ViGEm.Client.Targets;
using Nefarius.ViGEm.Client.Targets.Xbox360;
using NetJoy.Core.NetJoy.Packets;
using NetJoy.Core.Utils;
using NetJoy.Core.Utils.Controller;
using SharpDX.DirectInput;
using vJoyInterfaceWrap;
using NetJoy.Core.Utils.General;
using static System.Int16;

namespace NetJoy.Core.NetJoy.Client.Handling
Expand Down
13 changes: 2 additions & 11 deletions Core/NetJoy/Client/NetJoyClient.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using NetJoy.Core.Config;
using NetJoy.Core.NetJoy.Client.Handling;
using NetJoy.Core.NetJoy.Packets;
using NetJoy.Core.Utils;
using NetJoy.Core.Utils.General;
using Newtonsoft.Json;
using Encoding = System.Text.Encoding;

namespace NetJoy.Core.NetJoy.Client
{
public class NetJoyClient
{
private readonly Configuration _configuration; // the config file

private Socket _client; //the client socket
private JoyHandler _joyHandler; // the joystick handler instance

// ManualResetEvent instances signal completion.
private readonly ManualResetEvent _connectDone = new ManualResetEvent(false);

public NetJoyClient(Configuration configuration)
{
_configuration = configuration;
}


/// <summary>
/// Start the net joy client
/// </summary>
Expand Down
10 changes: 2 additions & 8 deletions Core/NetJoy/NetJoyManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using NetJoy.Core.Config;
using System.Threading.Tasks;
using NetJoy.Core.NetJoy.Client;
using NetJoy.Core.NetJoy.Server;
using NetJoy.Core.Utils;
Expand All @@ -10,14 +7,11 @@ namespace NetJoy.Core.NetJoy
{
public class NetJoyManager
{

private readonly Configuration _config;
private readonly NetJoyServer _server;
private readonly NetJoyClient _client;

public NetJoyManager(Configuration config, NetJoyServer server, NetJoyClient client)
public NetJoyManager(NetJoyServer server, NetJoyClient client)
{
_config = config;
_server = server;
_client = client;
}
Expand Down
1 change: 1 addition & 0 deletions Core/NetJoy/Server/NetJoyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NetJoy.Core.Config;
using NetJoy.Core.NetJoy.Packets;
using NetJoy.Core.Utils;
using NetJoy.Core.Utils.General;
using Newtonsoft.Json;
using SharpDX.DirectInput;

Expand Down
28 changes: 8 additions & 20 deletions Core/NetJoy/Server/NgrokUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Net;
using NetJoy.Core.Config;
using NetJoy.Core.Utils;
using NetJoy.Core.Utils.General;
using Newtonsoft.Json.Linq;

namespace NetJoy.Core.NetJoy.Server
Expand All @@ -20,31 +21,31 @@ public void Start()
{


//get the address string for ngrock
//get the address string for Ngrock
var address = GetNgrok();

//if we already have an instance skip the spawning process
if (address != null)
{
Logger.Debug("Found existing ngrock instance @" + address);
Logger.Debug("Found existing Ngrock instance @" + address);
return;
}

//log that we couldn't find any instances
Logger.Debug("No existing ngrock instances. Spawning new instance.");
Logger.Debug("No existing Ngrock instances. Spawning new instance.");

//spawn a new ngrok instance
SpawnNgrock(_port);
SpawnNgrock();

//log that we created a new ngrock instance
Logger.Debug("Spawned ngrock instance @" + GetNgrok());
Logger.Debug("Spawned Ngrock instance @" + GetNgrok());
}

/// <summary>
/// Get data about the Ngrok instance from the local webserver
/// </summary>
/// <returns></returns>
public string GetNgrok()
private string GetNgrok()
{
var wr = WebRequest.Create("http://127.0.0.1:4040/api/tunnels");

Expand Down Expand Up @@ -82,21 +83,8 @@ public string GetNgrok()

}

//process for killing ngrok instances
private readonly Process _taskKill = new Process
{
StartInfo = new ProcessStartInfo()
{
UseShellExecute = false,
CreateNoWindow = true,
FileName = "taskkill.exe",
RedirectStandardOutput = true,
Arguments = "/f /im \"ngrok.exe\""
}
};

//Process for creating new ngrok instances
private void SpawnNgrock(int port)
private void SpawnNgrock()
{
new Process
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Utils/Controller/ControllerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NetJoy.Core.Utils.Controller
{
public class ControllerUtils
public static class ControllerUtils
{
/// <summary>
/// Get the Xbox360Button for the given string
Expand Down
2 changes: 1 addition & 1 deletion Core/Utils/General/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace NetJoy.Core.Utils
namespace NetJoy.Core.Utils.General
{
public static class Logger
{
Expand Down
1 change: 1 addition & 0 deletions Core/Utils/General/Prompts.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using NetJoy.Core.Utils.General;

namespace NetJoy.Core.Utils
{
Expand Down
6 changes: 0 additions & 6 deletions NetJoy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
<LangVersion>9</LangVersion>
</PropertyGroup>

<ItemGroup>
<Reference Include="vJoyInterfaceWrap, Version=0.2.1.6, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\..\Program Files\vJoy\x64\vJoyInterfaceWrap.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Nefarius.ViGEm.Client" Version="1.16.150" />
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ NetJoy is a bundled client/server application that can send joystick/controller
from one computer to another remotely over the network.

# Support
Currently the only supported platform is windows but linux support
is planned in the near future! This is due to using the windows binaries for "ngrok" and "taskkill".

Currently the only supported platform is Windows, Linux is planned in the future!

# Example Config
````toml
Expand All @@ -23,13 +21,14 @@ port = 6069
> EXTRA STEP FOR SERVERS
* Open config.toml and set isServer to true.
* Change port to your desired port number.
* configure ngrok to use your ngrok token [FROM HERE](https://ngrok.com/) by running
* configure ngrok using your ngrok token [FROM HERE](https://ngrok.com/) by running the below code in the NeyJoy Directory
```
cd PATH_TO_NETJOY_FOLDER
ngrok authtoken TOKEN_GOES_HERE
```

> EXTRA STEP FOR CLIENTS
* Install vJoy from [here](http://vjoystick.sourceforge.net/site/index.php/download-a-install/download)
* Install ViGEm from [here](https://github.com/ViGEm/ViGEmBus)
* Complete install & restart
> Both Clients & Servers
* Run NetJoy.exe & follow instructions.
* Run NetJoy.exe & follow instructions in the application for setting up your server/client.

0 comments on commit 1654f50

Please sign in to comment.