public void Install() { if (!File.Exists(_loaderFileName)) { InstallLoader(); } if (!File.Exists(_configFileName)) { InstallConfigFile(); } RuntimePlatform platform = Application.platform; if (File.Exists(_configFileName) && platform != RuntimePlatform.WindowsPlayer && platform != RuntimePlatform.WindowsEditor) { if (platform == RuntimePlatform.LinuxPlayer) { (this as LinuxDoorstopManager)?.GrantExecuteAccessForConfig(); RequiresRestart = true; } else if (platform == RuntimePlatform.OSXPlayer) { //todo add support for MacOS //(this as MacOSDoorstopManager)?.GrantExecuteAccessForConfig(); } } else { RequiresRestart = true; } _logger.Info("Doorstop installed successfully."); }
public void CreateUi(UIHelperBase helper, DoorstopManager manager) { _manager = manager; var uiHelper = helper as UIHelper; var panel = uiHelper.self as UIScrollablePanel; var label = panel.AddUIComponent <UILabel>(); label.relativePosition = new Vector3(10, 0, 10); label.processMarkup = true; StringBuilder builder = new StringBuilder(); StringBuilder internalBuilder = new StringBuilder(); bool anyError = false; foreach (KeyValuePair <string, PatchStatus> patchStatus in PatchLoaderStatusInfo.Statuses) { if (patchStatus.Value.HasError) { anyError = true; builder.Append(" ") .Append(patchStatus.Key) .Append(": <color ").Append(colorError).Append(">") .Append("Error (").Append(patchStatus.Value.ErrorMessage).AppendLine(") </color>"); } internalBuilder.Append(" ") .Append(patchStatus.Key) .Append(patchStatus.Value.HasError ? ": Error (" : ": OK") .Append(patchStatus.Value.HasError ? patchStatus.Value.ErrorMessage : "") .AppendLine(patchStatus.Value.HasError ? ")" : ""); } if (!anyError && PatchLoaderStatusInfo.Statuses.Count > 0) { builder.Append(" ") .Append("<color").Append(colorOk).Append(">").Append("All patches applied correctly").AppendLine("</color>").AppendLine(); } label.text = "Statuses:\n\n" + (PatchLoaderStatusInfo.Statuses.Count > 0 ? builder.ToString() : "No patches processed.\n"); _logger?.Info("Statuses:\n" + internalBuilder); UIHelper loaderGroup = helper.AddGroup("Loader") as UIHelper; var uiPanel = loaderGroup.self as UIPanel; _statusLabel = uiPanel.AddUIComponent <UILabel>(); _statusLabel.processMarkup = true; _upgradeButton = loaderGroup.AddButton("Upgrade", OnUpgrade) as UIButton; UpdateStatus(); }
// Blocker call public void Listen() { this._socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { this._socket.Bind(this._localEndPoint); this._socket.Listen(100); _logger.Info($"TCP port listening on: {this._localEndPoint}"); while (true) { _connAccepted.Reset(); this._socket.BeginAccept(new AsyncCallback(AcceptHandler), this._socket); _connAccepted.WaitOne(); } } catch (Exception e) { _logger.Fatal("Server socket error: " + e.ToString()); } }
/// <summary> /// Add player to the server /// </summary> /// <param name="player">Player</param> private void AddPlayer(Player player) { // Add to player list this._players.Add(player); // Send to user his server Id player.SendResponseId(); // TODO: If server data don't exists, send to user ResponseReloadServerConfig // TODO: Update data on lobby server // TODO: Emit internal event // Handle new player messages player.OnMessage += new PlayerMessageEventHandler(PlayerMessageHandler); // Send player connected event player.SendPlayerConnected(); _logger.Info($"New player <{player.Name}> connected from {player.Connection.Ip}"); }