Added snippets to unity plugin readme
This commit is contained in:
@@ -6,7 +6,8 @@ We've tried to replicate the behavior of the Unity3D LLAPI to make using ZeroTie
|
|||||||
|
|
||||||
To start things off, go check out [ZeroTierSockets_Demo.cs](). Here are some examples of how to use the `ZeroTierNetworkInterface`:
|
To start things off, go check out [ZeroTierSockets_Demo.cs](). Here are some examples of how to use the `ZeroTierNetworkInterface`:
|
||||||
|
|
||||||
## Server example
|
## Using ZeroTier Sockets API
|
||||||
|
### Server example
|
||||||
```
|
```
|
||||||
Thread connectThread = new Thread(() => {
|
Thread connectThread = new Thread(() => {
|
||||||
// Create ZeroTier-administered socket
|
// Create ZeroTier-administered socket
|
||||||
@@ -35,13 +36,12 @@ Thread connectThread = new Thread(() => {
|
|||||||
string msgstr = new string(msg);
|
string msgstr = new string(msg);
|
||||||
Debug.Log("MSG (" + bytes_read + "):" + msgstr);
|
Debug.Log("MSG (" + bytes_read + "):" + msgstr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connectThread.IsBackground = true;
|
connectThread.IsBackground = true;
|
||||||
connectThread.Start();
|
connectThread.Start();
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Client example
|
### Client example
|
||||||
|
|
||||||
```
|
```
|
||||||
Thread connectThread = new Thread(() => {
|
Thread connectThread = new Thread(() => {
|
||||||
@@ -49,9 +49,9 @@ Thread connectThread = new Thread(() => {
|
|||||||
int sock = zt.Socket ((int)AddressFamily.InterNetwork, (int)SocketType.Stream, (int)ProtocolType.Unspecified);
|
int sock = zt.Socket ((int)AddressFamily.InterNetwork, (int)SocketType.Stream, (int)ProtocolType.Unspecified);
|
||||||
zt.Connect (sock, "0.0.0.0",8000);
|
zt.Connect (sock, "0.0.0.0",8000);
|
||||||
zt.Write(sock, "Welcome to the machine!", 24);
|
zt.Write(sock, "Welcome to the machine!", 24);
|
||||||
});
|
});
|
||||||
connectThread.IsBackground = true;
|
connectThread.IsBackground = true;
|
||||||
connectThread.Start();
|
connectThread.Start();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ Thread connectThread = new Thread(() => {
|
|||||||
|
|
||||||
|
|
||||||
***
|
***
|
||||||
|
## Using the ZeroTier Low-level API (LLAPI)
|
||||||
## Creating a host and receiving data
|
### Creating a host and receiving data
|
||||||
|
|
||||||
```
|
```
|
||||||
public class MyObject
|
public class MyObject
|
||||||
@@ -98,7 +98,7 @@ public class MyObject
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Connecting to a server and sending a message
|
### Connecting to a server and sending a message
|
||||||
|
|
||||||
```
|
```
|
||||||
public class MyObject
|
public class MyObject
|
||||||
|
|||||||
Reference in New Issue
Block a user