// Use this for initialization void Start() { if (server == null) { players = new UCPlayer[maxConnections]; server = UCServer.Init(this, portNumber, maxConnections, debug); } }
/// <summary> /// Returns the existing instance or create a new instance /// of UCServer. /// </summary> /// <param name="handler">An instance of ICommandHandler that /// handles the commands received.</param> /// <param name="port">Port number for the server socket to /// bind to. Default port is 28910.</param> /// <param name="maxConn">Maximum number of connections for /// the server. Default value is 4.</param> /// <param name="debug">Writes log msg to console if debug /// == true.</param> /// <returns>A newly initialised instance or an existing /// instance of UCServer.</returns> public static UCServer Init(ICommandHandler handler, int port = DefaultPort, int maxConn = DefaultMaxConnections, bool debug = false) { DebugUtilities.Enable = debug; if (instance == null) { instance = new UCServer(port, maxConn); instance.Start(); // Start server. } instance.cmdHandler = handler; return(instance); }