2020-08-05 18:50:28 +02:00
|
|
|
|
using UnityEngine;
|
2020-08-07 20:20:13 +02:00
|
|
|
|
using NeonTea.Quakeball.Networking.Instances;
|
2020-08-05 18:50:28 +02:00
|
|
|
|
using NeonTea.Quakeball.TeaNet.Peers;
|
|
|
|
|
using System.Collections.Generic;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
2020-08-07 20:20:13 +02:00
|
|
|
|
namespace NeonTea.Quakeball.Networking {
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
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-07 03:46:09 +02:00
|
|
|
|
public NetInstance Instance;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
2020-08-05 03:21:04 +02:00
|
|
|
|
public void StartClient(string address, int port, PeerMessageListener listener) {
|
2020-08-07 03:46:09 +02:00
|
|
|
|
Instance = new Client();
|
|
|
|
|
Instance.Start(address, port, listener);
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 03:21:04 +02:00
|
|
|
|
public void StartServer(string address, int port, PeerMessageListener listener) {
|
2020-08-07 03:46:09 +02:00
|
|
|
|
Instance = new Server();
|
|
|
|
|
Instance.Start(address, port, listener);
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|
2020-08-05 03:21:04 +02:00
|
|
|
|
|
2020-08-07 03:46:09 +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;
|
|
|
|
|
}
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|