diff --git a/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate b/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate index 0b12d04..fc06d3d 100644 Binary files a/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate and b/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/integrations/Unity3D/Assets/Demo.cs b/integrations/Unity3D/Assets/Demo.cs index 72b8032..78a025b 100644 --- a/integrations/Unity3D/Assets/Demo.cs +++ b/integrations/Unity3D/Assets/Demo.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Threading; using System.Runtime.Serialization.Formatters.Binary; using System.IO; +using UnityEngine.UI; public class Demo : MonoBehaviour { @@ -52,8 +53,64 @@ public class Demo : MonoBehaviour networkTestThread.Start(); } + // Demo button methods + public void Join() + { + GameObject go = GameObject.Find ("inputNetworkID"); + InputField input = go.GetComponents () [0]; + Debug.Log ("Joining: " + input.text); + zt.JoinNetwork (input.text); + } + + public void Leave() + { + GameObject go = GameObject.Find ("inputNetworkID"); + InputField input = go.GetComponents () [0]; + Debug.Log ("Leaving: " + input.text); + zt.LeaveNetwork (input.text); + } + + + public void Connect() + { + GameObject go = GameObject.Find ("inputServerAddress"); + //Text text = go.GetComponents ()[0]; + InputField input = go.GetComponents () [0]; + Debug.Log ("Connecting to: " + input.text); + //zt.Connect(0, input.text + } + + public void Disconnect() + { + GameObject go = GameObject.Find ("inputServerAddress"); + InputField text = go.GetComponents () [0]; + Debug.Log ("Disconnecting from: " + text.text); + } + + + public void SendMessage() + { + GameObject go = GameObject.Find ("inputMessage"); + InputField text = go.GetComponents () [0]; + Debug.Log ("Sending Message: " + text.text); + } + + void Start() { + // Set defaults + InputField input; + GameObject go; + go = GameObject.Find ("inputNetworkID"); + input = go.GetComponents () [0]; + input.text = "565799d8f6e1c11a"; + go = GameObject.Find ("inputServerAddress"); + input = go.GetComponents () [0]; + input.text = "172.22.211.245"; + go = GameObject.Find ("inputMessage"); + input = go.GetComponents () [0]; + input.text = "Welcome to the machine"; + // Create new instance of ZeroTier in separate thread zt = new ZeroTierNetworkInterface ("/Users/Joseph/utest2"); diff --git a/integrations/Unity3D/Assets/MainScene.unity b/integrations/Unity3D/Assets/MainScene.unity index e1f3e57..7b4d9f7 100644 Binary files a/integrations/Unity3D/Assets/MainScene.unity and b/integrations/Unity3D/Assets/MainScene.unity differ diff --git a/src/SDK_ServiceSetup.cpp b/src/SDK_ServiceSetup.cpp index eaa406e..6ea56fa 100644 --- a/src/SDK_ServiceSetup.cpp +++ b/src/SDK_ServiceSetup.cpp @@ -63,6 +63,20 @@ std::string netDir; extern "C" { #endif +#if defined(__UNITY_3D__) + // .NET Interop-friendly debug mechanism + typedef void (*FuncPtr)( const char * ); + FuncPtr Debug; + + void SetDebugFunction( FuncPtr fp ) { Debug = fp; } + + // Starts a service at the specified path + void unity_start_service(char * path, int len) { + Debug(path); + init_service(INTERCEPT_DISABLED, path); + } +#endif + void join_network(const char * nwid) { std::string confFile = netDir + "/" + nwid + ".conf"; @@ -80,11 +94,13 @@ extern "C" { zt1Service->leave(nwid); } - void zt_join_network(std::string nwid) { - join_network(nwid.c_str()); + void zt_join_network(char * nwid) { + //Debug(nwid.c_str()); + join_network(nwid); } - void zt_leave_network(std::string nwid) { - leave_network(nwid.c_str()); + void zt_leave_network(char * nwid) { + //Debug(nwid.c_str()); + leave_network(nwid); } bool zt_is_running() { @@ -94,21 +110,6 @@ extern "C" { zt1Service->terminate(); } -#if defined(__UNITY_3D__) - // .NET Interop-friendly debug mechanism - typedef void (*FuncPtr)( const char * ); - FuncPtr Debug; - - void SetDebugFunction( FuncPtr fp ) { Debug = fp; } - - // Starts a service at the specified path - void unity_start_service(char * path, int len) { - Debug(path); - init_service(INTERCEPT_DISABLED, path); - } -#endif - - #if !defined(__ANDROID__) /* * Starts a service thread and performs basic setup tasks