Skip to content

Commit

Permalink
tweaked proxy connect UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjarv committed Feb 14, 2017
1 parent 88f98a7 commit ab295db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions JoystickVisualizer/Assets/JoystickSocketReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Net.Sockets;
using System;
using JoystickProxy;
using UnityEngine.UI;

public class JoystickSocketReader : MonoBehaviour {
private int HAT_ANGLE = 8;
Expand All @@ -24,7 +25,7 @@ public class JoystickSocketReader : MonoBehaviour {

public GameObject connectionError;

public GameObject HostInputField;
public GameObject HostInputPanel;

public string Host = "127.0.0.1";
public int Port = 9998;
Expand Down Expand Up @@ -122,16 +123,13 @@ public class JoystickSocketReader : MonoBehaviour {
private WarthogJoystick warthogJoystick;
private WarthogThrottle warthogThrottle;

public void Host_Changed(string host)
{
Host = host;
connectionError.SetActive(false);
if (client != null)
{
client.Close ();
}
reconnect ();
}
public InputField ProxyHostInputField;

public void UpdateHost()
{
Host = ProxyHostInputField.text;
reconnect();
}

void Start () {
warthogJoystick = new WarthogJoystick();
Expand Down Expand Up @@ -168,7 +166,7 @@ void Start () {
}

void Update () {
if (HostInputField.activeInHierarchy || connectionError.activeInHierarchy)
if (HostInputPanel.activeInHierarchy || connectionError.activeInHierarchy)
{
// If we're inputting host, don't do anything
return;
Expand Down Expand Up @@ -239,6 +237,11 @@ void reconnect() {
{
lastMessage = DateTime.Now; // Reconnect attempt every other second

try
{
client.Close();
} catch(Exception) {}

client = new TcpClient();

var result = client.BeginConnect(Host, Port, null, null);
Expand Down
Binary file modified JoystickVisualizer/Assets/JoystickVisualizer.unity
Binary file not shown.
Binary file modified JoystickVisualizer/ProjectSettings/QualitySettings.asset
Binary file not shown.

0 comments on commit ab295db

Please sign in to comment.