using UnityEngine; using System; using NeonTea.Quakeball.Interface; using NeonTea.Quakeball.TeaNet.Peers; namespace NeonTea.Quakeball.Net { public class NetChaperone : MonoBehaviour, PeerMessageListener { private Terminal Terminal; private void Start() { if (Terminal.Singleton != null) { Terminal = Terminal.Singleton; Terminal.RegisterCommand("host", Host); } } private bool Host(string[] args) { if (args.Length > 2) { Terminal.AddMessage($"Can't accept more than 2 arguments."); return false; } string addr = "0.0.0.0"; string portstr = "8080"; if (args.Length == 1) { portstr = args[0]; } else if (args.Length == 2) { addr = args[0]; portstr = args[1]; } int port; if (!Int32.TryParse(portstr, out port)) { return false; } Net.Singleton.StartServer(addr, port, this); return true; } public void Message(string msg) { Terminal.AddMessage(msg); } public void Err(string err) { } } }