2020-08-02 02:50:01 +02:00
|
|
|
|
using UnityEngine;
|
2020-08-02 20:32:30 +02:00
|
|
|
|
using NeonTea.Quakeball.Net.Peers;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace NeonTea.Quakeball.Net {
|
|
|
|
|
|
2020-08-02 20:32:30 +02:00
|
|
|
|
public class Net {
|
|
|
|
|
public static Net Singleton = new Net();
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
2020-08-02 20:32:30 +02:00
|
|
|
|
private Peer Endpoint;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
2020-08-02 20:32:30 +02:00
|
|
|
|
public void Start(Peer endpoint, string host, int port) {
|
2020-08-02 02:50:01 +02:00
|
|
|
|
if (Endpoint != null) {
|
|
|
|
|
Debug.Log("Can not start multiple endpoints at once! Use Server if multiple connections are required.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Endpoint = endpoint;
|
|
|
|
|
Endpoint.Start(host, port);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-02 20:32:30 +02:00
|
|
|
|
public void Stop(DisconnectReason reason) {
|
|
|
|
|
if (Endpoint != null) {
|
|
|
|
|
Endpoint.Stop(reason);
|
|
|
|
|
Endpoint = null;
|
|
|
|
|
}
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|