Updated Unity3D integration
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,8 @@ public class Demo : MonoBehaviour
|
|||||||
private ZeroTierNetworkInterface zt;
|
private ZeroTierNetworkInterface zt;
|
||||||
string nwid = "";
|
string nwid = "";
|
||||||
|
|
||||||
|
int server_connection_socket; // The "connection id"
|
||||||
|
|
||||||
private void zt_sample_network_test_thread()
|
private void zt_sample_network_test_thread()
|
||||||
{
|
{
|
||||||
print("test_network");
|
print("test_network");
|
||||||
@@ -70,32 +72,39 @@ public class Demo : MonoBehaviour
|
|||||||
zt.LeaveNetwork (input.text);
|
zt.LeaveNetwork (input.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Connect()
|
public void Connect()
|
||||||
{
|
{
|
||||||
GameObject go = GameObject.Find ("inputServerAddress");
|
GameObject addr_go = GameObject.Find ("inputServerAddress");
|
||||||
//Text text = go.GetComponents<Text> ()[0];
|
GameObject port_go = GameObject.Find ("inputServerPort");
|
||||||
InputField input = go.GetComponents<InputField> () [0];
|
InputField addr = addr_go.GetComponents<InputField> () [0];
|
||||||
Debug.Log ("Connecting to: " + input.text);
|
InputField port = port_go.GetComponents<InputField> () [0];
|
||||||
//zt.Connect(0, input.text
|
Debug.Log ("Connecting to: " + addr.text + ":" + port.text);
|
||||||
|
byte error = 0;
|
||||||
|
server_connection_socket = zt.Connect (0, addr.text, int.Parse (port.text), out error);
|
||||||
|
Debug.Log ("server_connection_socket = " + server_connection_socket);
|
||||||
|
Debug.Log ("Conenct(): " + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
GameObject go = GameObject.Find ("inputServerAddress");
|
GameObject addr_go = GameObject.Find ("inputServerAddress");
|
||||||
InputField text = go.GetComponents<InputField> () [0];
|
GameObject port_go = GameObject.Find ("inputServerAddress");
|
||||||
Debug.Log ("Disconnecting from: " + text.text);
|
InputField addr = addr_go.GetComponents<InputField> () [0];
|
||||||
|
InputField port = port_go.GetComponents<InputField> () [0];
|
||||||
|
Debug.Log ("Disconnecting from: " + addr.text + ":" + port.text);
|
||||||
|
Debug.Log ("Disconnect(): " + zt.Disconnect (server_connection_socket));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SendMessage()
|
public void SendMessage()
|
||||||
{
|
{
|
||||||
GameObject go = GameObject.Find ("inputMessage");
|
GameObject go = GameObject.Find ("inputMessage");
|
||||||
InputField text = go.GetComponents<InputField> () [0];
|
InputField msg = go.GetComponents<InputField> () [0];
|
||||||
Debug.Log ("Sending Message: " + text.text);
|
Debug.Log ("Sending Message: " + msg.text);
|
||||||
|
byte error = 0;
|
||||||
|
zt.Send (server_connection_socket, msg.text.ToCharArray (), msg.text.ToCharArray ().Length, out error);
|
||||||
|
Debug.Log ("Send(): " + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
// Set defaults
|
// Set defaults
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user