quakeball/Assets/Scripts/Net/Net.cs
2020-08-07 05:36:20 +03:00

35 lines
947 B
C#

using UnityEngine;
using NeonTea.Quakeball.Net.Instances;
using NeonTea.Quakeball.TeaNet.Peers;
using System.Collections.Generic;
namespace NeonTea.Quakeball.Net {
public class Net {
public static Net Singleton = new Net();
public NetInstance Instance;
public void StartClient(string address, int port, PeerMessageListener listener) {
Instance = new Client();
Instance.Start(address, port, listener);
}
public void StartServer(string address, int port, PeerMessageListener listener) {
Instance = new Server();
Instance.Start(address, port, listener);
}
public static void Quit() {
if (Singleton.Instance != null) {
Singleton.Instance.Stop();
}
}
[RuntimeInitializeOnLoadMethod]
static void RunOnStart() {
Application.quitting += Quit;
}
}
}