quakeball/Assets/Scripts/Net/Net.cs

29 lines
759 B
C#
Raw Normal View History

using UnityEngine;
2020-08-02 20:32:30 +02:00
using NeonTea.Quakeball.Net.Peers;
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 20:32:30 +02:00
private Peer Endpoint;
2020-08-02 20:32:30 +02:00
public void Start(Peer endpoint, string host, int port) {
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;
}
}
}
}