quakeball/Assets/Scripts/Networking/Net.cs

35 lines
961 B
C#
Raw Normal View History

using UnityEngine;
using NeonTea.Quakeball.Networking.Instances;
using NeonTea.Quakeball.TeaNet.Peers;
using System.Collections.Generic;
namespace NeonTea.Quakeball.Networking {
2020-08-02 20:32:30 +02:00
public class Net {
public static Net Singleton = new Net();
public NetInstance Instance;
2020-08-05 03:21:04 +02:00
public void StartClient(string address, int port, PeerMessageListener listener) {
Instance = new Client();
Instance.Start(address, port, listener);
}
2020-08-05 03:21:04 +02:00
public void StartServer(string address, int port, PeerMessageListener listener) {
Instance = new Server();
Instance.Start(address, port, listener);
}
2020-08-05 03:21:04 +02:00
public static void Quit() {
2020-08-07 04:36:20 +02:00
if (Singleton.Instance != null) {
Singleton.Instance.Stop();
}
2020-08-05 03:21:04 +02:00
}
[RuntimeInitializeOnLoadMethod]
static void RunOnStart() {
Application.quitting += Quit;
}
}
}