/// <summary> /// Get the Server Browse Data /// </summary> /// <param name="ipAddress"></param> /// <param name="specification"></param> /// <returns></returns> private static ServerBrowserData[] GetServerBrowseData(string ipAddress, Softing.OPCToolbox.EnumOPCSpecification specification) { ServerBrowserData[] serverData = null; if (string.IsNullOrEmpty(ipAddress)) { return(null); } Softing.OPCToolbox.Client.ServerBrowser serverBrowser = new ServerBrowser(ipAddress); ExecutionOptions executionOptions = new ExecutionOptions(); try { if (ResultCode.SUCCEEDED(serverBrowser.Browse( specification, EnumServerBrowserData.ALL, out serverData, executionOptions))) { return(serverData); } } catch (Exception ex) { MessageBox.Show(ex.Message, DemoClient.Properties.Resources.DEMO_CLIENT, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); }
public async Task <int> GetServerInfo(uint appId, Action <gameserveritem_t> act, List <Tuple <string, string> > filter) { using (var sb = new ServerBrowser(_sessionLocator.Session)) { using (sb.ServerInfoReceived.Subscribe(act)) return(await sb.GetServerList(appId, filter).ConfigureAwait(false)); } }
private void CreateBrowseTree(string ipAddress, EnumOPCSpecification specification, TreeNode parent) { try { parent.Nodes.Clear(); Softing.OPCToolbox.Client.ServerBrowser serverBrowser = new ServerBrowser(ipAddress); ServerBrowserData[] serverData = null; if (ResultCode.SUCCEEDED(serverBrowser.Browse( specification, EnumServerBrowserData.ALL, out serverData, m_executionOptions))) { for (int i = 0; i < serverData.Length; i++) { TreeNode aNode = null; if (serverData[i].Description != String.Empty) { aNode = new TreeNode(serverData[i].Description, 7, 7); aNode.Tag = serverData[i].Url; parent.Nodes.Add(aNode); } if (serverData[i].ClsId != String.Empty) { TreeNode clsID = new TreeNode(serverData[i].ClsId, 5, 5); clsID.Tag = serverData[i].Url; aNode.Nodes.Add(clsID); } if (serverData[i].ProgId != String.Empty) { TreeNode progID = new TreeNode(serverData[i].ProgId, 5, 5); progID.Tag = serverData[i].Url; aNode.Nodes.Add(progID); } if (serverData[i].ProgIdVersionIndependent != String.Empty) { TreeNode vprogID = new TreeNode(serverData[i].ProgIdVersionIndependent, 5, 5); vprogID.Tag = serverData[i].Url; aNode.Nodes.Add(vprogID); } } //for } //if else { } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public override void OnTransitionIn() { _serverBrowser = new ServerBrowser(); Logger.Write("Entering TitleMenuState"); Engine.ShowSplashImage(Textures.MenuBackground); Engine.Gui.Desktop.Visible = true; Engine.Gui.Desktop.Transparent = true; LoadUI(); }
public void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Debug.Log("Scene Loaded: " + scene.name); if (scene.name == "TitleScreen") { serverBrowser = GameObject.Find("ServerBrowserCanvas").GetComponent <ServerBrowser>(); lobbyManager = transform.Find("NetworkObjects").gameObject.GetComponent <LobbyManager>(); base.StartMatchMaker(); StartCoroutine(AutoRefreshServerBrowser()); } }
private void ServersRefreshDoWork(object sender, DoWorkEventArgs e) { var result = new KeyValuePair <LocalHostNode, List <ServerDescription> >( (LocalHostNode)e.Argument, new List <ServerDescription>(10)); e.Result = result; using (var @enum = new ServerBrowser()) result.Value.AddRange(@enum .GetEnumerator(DAServer.Version10, DAServer.Version20) .TakeWhile(server => !worker.CancellationPending)); }
public void RefreshServerList() { this.refreshButton.IsEnabled = false; this.refreshButton.Opacity = 0.2f; SteamClient.Needed(); this.ClearList(); this.detailsLabel.Text = "Updating.."; this.serverRefresh = ServerBrowser.SteamServers_Fetch(1069, this.AddServerCallback, this.FinServerCallback); if (this.serverRefresh == IntPtr.Zero) { UnityEngine.Debug.Log("Error! Couldn't refresh servers!!"); } }
public ServerHost(string ipAddress) { ServersOnLocalHost = new List <Server>(); using (var @enum = new ServerBrowser(ipAddress)) { var serverDescriptions = @enum.GetEnumerator(DaServer.VersionOpc10, DaServer.VersionPoc20, DaServer.VersionOpc30, DaServer.VersionXml10); foreach (var d in serverDescriptions) { ServersOnLocalHost.Add(new Server(d)); } } }
// Use this for initialization void Start() { serverBrowser = GameObject.Find("ServerBrowserCanvas").GetComponent <ServerBrowser>(); lobbyManager = transform.Find("NetworkObjects").gameObject.GetComponent <LobbyManager>(); networkDiscovery = GetComponent <NetworkDiscovery>(); connectionConfig.IsAcksLong = true; connectionConfig.ResendTimeout = 1500; connectionConfig.NetworkDropThreshold = 90; connectionConfig.MaxSentMessageQueueSize = 1024; connectionConfig.MaxCombinedReliableMessageCount = 1; base.StartMatchMaker(); StartCoroutine(AutoRefreshServerBrowser()); SceneManager.sceneLoaded += OnSceneLoaded; }
public static List <string> GetOpcServers(string host) { List <String> OpcServers = new List <string>(); try { ServerBrowser browser = new ServerBrowser(host); foreach (ServerDescription OpcServer in browser.GetEnumerator(DAServer.Version10, DAServer.Version20)) { OpcServers.Add(OpcServer.ProgramId); } return(OpcServers); } catch (Exception e) { return(OpcServers); } }
private void CreateJoinServerButtons() { var serverBrowser = new ServerBrowser(); var y = 300; const int buttonHeight = 23; foreach (var host in serverBrowser.GetHosts()) { var widget = Engine.Gui.CreateButton( host.Hostname, new Vector2(250, y), new Vector2(300, buttonHeight) ); var buttonHost = host; widget.Click += (sender, args) => ConnectToServer(buttonHost.Hostname, buttonHost.Port); _joinServerButtonIds.Add(widget.Id); y += (int)(buttonHeight * 1.5f); } }
private void WorkerDoWork(object sender, DoWorkEventArgs e) { CreateWcfClient(); AddMessageLineSafe("Сравнение версий"); var newOnly = (bool)e.Argument; var clientFiles = newOnly ? ClientBrowser.GetFileVersions() : new List <FileVersion>(); var serverFiles = ServerBrowser.GetFileVersions(targetSystem); if (serverFiles.Count == 0) { LogHelper.InfoFormat("{0} файлов на клиенте, файлов на сервере нет", clientFiles.Count); return; } var lackFiles = ClientBrowser.CompareWithServer(serverFiles, clientFiles); if (lackFiles.Count == 0) { LogHelper.InfoFormat("{0} файлов на клиенте, {1} файлов на сервере - нет файлов для обновления", clientFiles.Count, serverFiles.Count); return; } AddMessageLineSafe(string.Format("{0} файлов нуждаются в обновлении" + Environment.NewLine, lackFiles.Count)); var msg = "Загрузка следующих обновлений:" + Environment.NewLine + string.Join(Environment.NewLine, lackFiles); AddMessageLineSafe(msg); LogHelper.Info(msg); var percent = 0; IUpdateManager channel = null; ReportProgressForLocalServerUnitManager(0, lackFiles.Count, false); var updatedCount = 0; foreach (var file in lackFiles) { if (worker.CancellationPending) { break; } var fileClientPath = string.Format("{0}{1}", ClientBrowser.ownPath, file); // абсолютное имя файла на клиенте var targetDir = Path.GetDirectoryName(fileClientPath); try { if (!Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } } catch (Exception ex) { LogHelper.ErrorFormat("Error creating directory {0}: {1}", targetDir, ex); continue; } if (!TryDownloadFile(file, fileClientPath, ref channel)) { DisplayError(); } else { AddMessageLineSafe("Обновлен " + file.FileName); LogHelper.Info("Обновлен " + file.FileName); } worker.ReportProgress(100 * (++percent) / lackFiles.Count); updatedCount++; ReportProgressForLocalServerUnitManager(updatedCount, lackFiles.Count - updatedCount, false); } ReportProgressForLocalServerUnitManager(lackFiles.Count, 0, true); }
private void Add_Server(int iMaxPlayers, int iCurrentPlayers, int iPing, uint iLastPlayed, [In] string strHostname, [In] string strAddress, int iPort, int iQueryPort, [In] string tags, bool bPassworded, int iType) { ulong num; string str = string.Concat(strAddress, ":", iPort.ToString()); ServerBrowser.Server server = new ServerBrowser.Server() { name = strHostname, address = strAddress, maxplayers = iMaxPlayers, currentplayers = iCurrentPlayers, ping = iPing, lastplayed = iLastPlayed, port = iPort, queryport = iQueryPort, fave = FavouriteList.Contains(str) }; if (server.name.Length > 64) { server.name = server.name.Substring(0, 64); } if (this.ShouldIgnoreServer(server)) { return; } ServerBrowser serverBrowser = this; serverBrowser.playerCount = serverBrowser.playerCount + iCurrentPlayers; ServerBrowser serverBrowser1 = this; serverBrowser1.serverCount = serverBrowser1.serverCount + 1; ServerBrowser serverBrowser2 = this; serverBrowser2.slotCount = serverBrowser2.slotCount + iMaxPlayers; this.needsServerListUpdate = true; int num1 = (int)((float)this.playerCount / (float)this.slotCount * 100f); this.detailsLabel.Text = string.Concat(new string[] { "Found ", this.playerCount.ToString(), " players on ", this.serverCount.ToString(), " servers. We are at ", num1.ToString(), "% capacity." }); if (iType == 3) { this.servers[5].Add(server); this.categoryButtons[5].UpdateServerCount(this.servers[5].Count); return; } if (iType == 4) { int num2 = (int)POSIX.Time.ElapsedSecondsSince((int)server.lastplayed); string empty = string.Empty; if (num2 < 60) { empty = string.Concat(num2.ToString(), " seconds ago"); } else if (num2 < 3600) { int num3 = num2 / 60; empty = string.Concat(num3.ToString(), " minutes ago"); } else if (num2 >= 172800) { int num4 = num2 / 60 / 60 / 24; empty = string.Concat(num4.ToString(), " days ago"); } else { int num5 = num2 / 60 / 60; empty = string.Concat(num5.ToString(), " hours ago"); } ServerBrowser.Server server1 = server; server1.name = string.Concat(server1.name, " (", empty, ")"); this.servers[4].Add(server); this.categoryButtons[4].UpdateServerCount(this.servers[4].Count); return; } if (tags.Contains("official")) { this.servers[0].Add(server); this.categoryButtons[0].UpdateServerCount(this.servers[0].Count); return; } string[] strArrays = tags.Split(new char[] { ',' }); for (int i = 0; i < (int)strArrays.Length; i++) { string str1 = strArrays[i]; if (!str1.StartsWith("mp")) { if (!str1.StartsWith("cp")) { if (str1.StartsWith("sg:") && ulong.TryParse(str1.Substring(3), NumberStyles.HexNumber, null, out num)) { if (!SteamGroups.MemberOf(num)) { return; } this.servers[3].Add(server); this.categoryButtons[3].UpdateServerCount(this.servers[3].Count); return; } } } } if (tags.Contains("modded")) { this.servers[2].Add(server); this.categoryButtons[2].UpdateServerCount(this.servers[2].Count); return; } if (strHostname.Contains("oxide", true)) { return; } if (strHostname.Contains("rust++", true)) { return; } this.servers[1].Add(server); this.categoryButtons[1].UpdateServerCount(this.servers[1].Count); }
public static extern IntPtr SteamServers_Fetch(int serverVersion, ServerBrowser.funcServerAdd fnc, ServerBrowser.funcServerFinish fnsh);
private bool ShouldIgnoreServer(ServerBrowser.Server item) { string lower = item.name.ToLower(); if (lower.Contains("[color")) { return true; } if (lower.Contains("[sprite")) { return true; } if (lower.Contains("--")) { return true; } if (lower.Contains("%%")) { return true; } if (!char.IsLetterOrDigit(lower[0])) { return true; } if (!char.IsLetterOrDigit(lower[lower.Length - 1])) { return true; } string str = lower; for (int i = 0; i < str.Length; i++) { char chr = str[i]; if (!char.IsLetterOrDigit(chr)) { if (chr != '\'') { if (chr != '[') { if (chr != ']') { if (chr != '|') { if (chr != ' ') { if (chr != '-') { if (chr != '(') { if (chr != '%') { if (chr != ')') { if (chr != '\u005F') { if (chr != '@') { if (chr != '+') { if (chr != '&') { if (chr != ':') { if (chr != '/') { if (chr != '.') { if (chr != '?') { if (chr != '#') { if (chr != '!') { if (chr != ',') { return true; } } } } } } } } } } } } } } } } } } } } } } if (item.currentplayers > item.maxplayers) { return true; } if (item.currentplayers > 500) { return true; } return false; }
public void InitializeMenu() { int width = GameConstants.PLAYER_WIDTH; animations.Add("walkDown", new Rectangle[4] { new Rectangle(0, 0, width, width), new Rectangle(32, 0, width, width), new Rectangle(64, 0, width, width), new Rectangle(96, 0, width, width) }); menuMotto = ContentChest.Instance.menuMottos[random.Next(0, ContentChest.Instance.menuMottos.Count)]; menuBackground = new MenuBackground(); MediaPlayer.Volume = GameOptions.Instance.MUSIC_VOLUME; resolutions = new List <string>(); resolutions.Add("1920x1080"); resolutions.Add("1280x720"); try { MediaPlayer.Play(ContentChest.Instance.menuMusic); MediaPlayer.IsRepeating = true; } catch (Exception e) { Debug.Write(e); Debug.WriteLine("No music found to play."); } string playGameString = "Login"; string optionsString = "Options"; string quitString = "Quit"; string backString = "Back"; string refreshString = "Refresh"; string musicUp = "+"; string musicDown = "-"; int padding = 20; menuButtons = new List <Button>(); optionsButtons = new List <Button>(); serverBrowserButtons = new List <Button>(); loginMenu = new List <Button>(); currentResolution = Resolution.GameWidth + "x" + Resolution.GameHeight; float strWidth = ContentChest.Instance.menuFont.MeasureString(currentResolution).X; menuButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(playGameString).X / 2, Resolution.GameHeight / 2), playGameString, ButtonTag.LOGIN, ContentChest.Instance.menuFont, new Color(231, 231, 231), true)); menuButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(optionsString).X / 2, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(playGameString).Y + padding), optionsString, ButtonTag.OPTIONS, ContentChest.Instance.menuFont, new Color(210, 210, 210), true)); menuButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(quitString).X / 2, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(playGameString).Y * 2 + padding * 2), quitString, ButtonTag.QUIT, ContentChest.Instance.menuFont, new Color(210, 210, 210), true)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(backString).X / 2, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(playGameString).Y * 5), backString, ButtonTag.BACK, ContentChest.Instance.menuFont, new Color(210, 210, 210), true)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 - 50, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicDown).Y - 200), musicDown, ButtonTag.MUSICDOWN, ContentChest.Instance.menuFont, new Color(210, 210, 210), false)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 + 50, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicUp).Y - 200), musicUp, ButtonTag.MUSICUP, ContentChest.Instance.menuFont, new Color(210, 210, 210), false)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 - 50, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicDown).Y - 100), musicDown, ButtonTag.EFFECTDOWN, ContentChest.Instance.menuFont, new Color(210, 210, 210), false)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(musicDown).X / 2 + 50, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicUp).Y - 100), musicUp, ButtonTag.EFFECTUP, ContentChest.Instance.menuFont, new Color(210, 210, 210), false)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString("<").X / 2 - 50 - strWidth, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(musicDown).Y + 0), "<", ButtonTag.RESOLUTIONDOWN, ContentChest.Instance.menuFont, new Color(210, 210, 210), false)); optionsButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(">").X / 2 + 50 + strWidth, Resolution.GameHeight / 2 + ContentChest.Instance.menuFont.MeasureString(Resolution.GameWidth + "x" + Resolution.GameHeight).Y + 0), ">", ButtonTag.RESOLUTIONUP, ContentChest.Instance.menuFont, new Color(210, 210, 210), false)); userNameBox = new Textbox((int)(Resolution.GameWidth / 2), (int)(Resolution.GameHeight / 2), 10, "Username", false); passWordBox = new Textbox((int)(Resolution.GameWidth / 2), (int)(Resolution.GameHeight / 2 + padding * 5), 10, "Password", true); loginMenu.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString("Connect").X / 2, (int)(Resolution.GameHeight / 2 + padding * 9)), "Connect", ButtonTag.LOGIN, ContentChest.Instance.menuFont, new Color(231, 231, 231), true)); loginMenu.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(backString).X / 2, (int)(Resolution.GameHeight / 2 + padding * 11)), backString, ButtonTag.BACK, ContentChest.Instance.menuFont, new Color(231, 231, 231), true)); serverBrowserButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(refreshString).X / 2, (int)(Resolution.GameHeight / 2 + padding * 9)), refreshString, ButtonTag.REFRESH, ContentChest.Instance.menuFont, new Color(231, 231, 231), true)); serverBrowserButtons.Add(new Button(new Vector2(Resolution.GameWidth / 2 - ContentChest.Instance.menuFont.MeasureString(backString).X / 2, (int)(Resolution.GameHeight / 2 + padding * 11)), backString, ButtonTag.BACK, ContentChest.Instance.menuFont, new Color(231, 231, 231), true)); serverBrowser = new ServerBrowser(); }