quakeball/Assets/Scripts/Net/Net.cs

33 lines
883 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() {
Singleton.Instance.Stop();
}
[RuntimeInitializeOnLoadMethod]
static void RunOnStart() {
Application.quitting += Quit;
}
}
}