public void addAndSelectServer(Server curr) { selectedServerFromList = true; settings.addServer(curr.name, curr.ip.ToString() + ":" + curr.port.ToString()); serverBox.Text = curr.name + "," + curr.ip.ToString() + ":" + curr.port.ToString(); serverList = null; }
private async void MasterServerRefreshButton_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(MasterServerBox.Text)) { try { serverList.Clear(); await LoadServerInfoFromFile("http://" + MasterServerBox.Text + "/serverlist.txt"); ServerListView.BeginUpdate(); ServerListView.Clear(); if (serverList.Count > 0) { var ColumnName = new ColumnHeader(); ColumnName.Text = "Name"; ColumnName.TextAlign = HorizontalAlignment.Center; ColumnName.Width = 284; ServerListView.Columns.Add(ColumnName); var ColumnClient = new ColumnHeader(); ColumnClient.Text = "Client"; ColumnClient.TextAlign = HorizontalAlignment.Center; ColumnClient.Width = 75; ServerListView.Columns.Add(ColumnClient); foreach (var server in serverList) { var serverItem = new ListViewItem(server.ServerName); var serverClient = new ListViewSubItem(serverItem, server.ServerClient); serverItem.SubItems.Add(serverClient); ServerListView.Items.Add(serverItem); } } else { MessageBox.Show("There are no servers available on this master server."); } ServerListView.EndUpdate(); } catch (Exception ex) { MessageBox.Show("Unable to load servers. (" + ex + ")"); } } }
private void RefreshServers_Click(object sender, EventArgs e) { if (!Int64.TryParse(Program.MainForm.PlaceID.Text, out PlaceId)) { return; } ServerListView.Items.Clear(); IRestResponse response; ServersInfo publicInfo = new ServersInfo(); ServersInfo vipInfo = new ServersInfo(); publicInfo.nextPageCursor = ""; vipInfo.nextPageCursor = ""; List <ServerData> servers = new List <ServerData>(); Task.Factory.StartNew(() => { while (publicInfo.nextPageCursor != null) { RestRequest request = new RestRequest("v1/games/" + Program.MainForm.PlaceID.Text + " /servers/public?sortOrder=Asc&limit=100" + (string.IsNullOrEmpty(publicInfo.nextPageCursor) ? "" : "&cursor=" + publicInfo.nextPageCursor), Method.GET); response = gamesclient.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { publicInfo = JsonConvert.DeserializeObject <ServersInfo>(response.Content); foreach (ServerData data in publicInfo.data) { data.type = "Public"; servers.Add(data); } } } if (AccountManager.SelectedAccount != null) { while (vipInfo.nextPageCursor != null) { RestRequest request = new RestRequest("v1/games/" + Program.MainForm.PlaceID.Text + " /servers/VIP?sortOrder=Asc&limit=100" + (string.IsNullOrEmpty(vipInfo.nextPageCursor) ? "" : "&cursor=" + vipInfo.nextPageCursor), Method.GET); request.AddCookie(".ROBLOSECURITY", AccountManager.SelectedAccount.SecurityToken); request.AddHeader("Accept", "application/json"); response = gamesclient.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { vipInfo = JsonConvert.DeserializeObject <ServersInfo>(response.Content); foreach (ServerData data in vipInfo.data) { data.id = data.name; data.type = "VIP"; servers.Add(data); } } } } ServerListView.SetObjects(servers); }); }
private void SearchPlayer_Click(object sender, EventArgs e) { if (AccountManager.SelectedAccount == null) { MessageBox.Show("Select an account on the main form", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int UserID = AccountManager.GetUserID(Username.Text); if (UserID < 0) { MessageBox.Show("Failed to get UserID of " + Username.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string token = AccountManager.SelectedAccount.SecurityToken; RestRequest request = new RestRequest("headshot-thumbnail/json?userId=" + UserID.ToString() + "&width=48&height=48", Method.GET); request.AddCookie(".ROBLOSECURITY", token); request.AddHeader("Accept", "application/json"); request.AddHeader("Host", "www.roblox.com"); IRestResponse response = rbxclient.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("Failed to get AvatarUrl of " + Username.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Avatar avatar = JsonConvert.DeserializeObject <Avatar>(response.Content); int index = 0; request = new RestRequest("games/getgameinstancesjson?placeId=" + Program.MainForm.PlaceID.Text + "&startIndex=" + index.ToString()); request.AddCookie(".ROBLOSECURITY", token); request.AddHeader("Host", "www.roblox.com"); response = rbxclient.Execute(request); if (response.StatusCode != HttpStatusCode.OK) { MessageBox.Show("Failed to get game instances, try selecting a different account", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } GameInstancesCollection instances = JsonConvert.DeserializeObject <GameInstancesCollection>(response.Content); string UserFound = ""; ServerData serverData = new ServerData(); foreach (GameInstance t in instances.Collection) { foreach (GamePlayer p in t.CurrentPlayers) { if (p.Thumbnail.Url == avatar.Url) { UserFound = t.Guid; } } } while (instances.Collection.Count != 0) { if (!string.IsNullOrEmpty(UserFound)) { break; } index += 10; request = new RestRequest("games/getgameinstancesjson?placeId=" + Program.MainForm.PlaceID.Text + "&startIndex=" + index.ToString()); request.AddCookie(".ROBLOSECURITY", token); request.AddHeader("Host", "www.roblox.com"); response = rbxclient.Execute(request); instances = JsonConvert.DeserializeObject <GameInstancesCollection>(response.Content); if (instances == null) { break; } foreach (GameInstance t in instances.Collection) { foreach (GamePlayer p in t.CurrentPlayers) { if (p.Thumbnail.Url == avatar.Url) { UserFound = t.Guid; serverData.id = t.Guid; serverData.playing = t.CurrentPlayers.Count; serverData.ping = t.Ping; serverData.fps = t.Fps; } } } } if (!string.IsNullOrEmpty(UserFound)) { ServerListView.ClearObjects(); ServerListView.SetObjects(new List <ServerData> { serverData }); } else { MessageBox.Show("User not found!", "Search", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
private void serverListButton_Click(object sender, RoutedEventArgs e) { serverList = new ServerListView(); serverList.chooseServer += addAndSelectServer; serverList.begin(); }
internal Connection(IClientConnectionHelper client, ServerConnection serverConnection) : this() { if (client == null) { throw new ArgumentNullException(nameof(client)); } SafeServerName = serverConnection.ServerName.Replace(".", "_"); ServerConnection = serverConnection ?? throw new ArgumentNullException(nameof(serverConnection)); Client = new MessageClient(serverConnection.ServerName, (int)serverConnection.ServerPort); PrimaryTab = new TabPage(serverConnection.ServerName); TabControl ServerTab = new TabControl(); ServerTab.Left = 3; ServerTab.Top = 3; ServerTab.Width = PrimaryTab.Width - 6; ServerTab.Height = PrimaryTab.Height - 6; ServerTab.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; PrimaryTab.Controls.Add(ServerTab); TabPage generalPage = new TabPage("General"); ServerTab.TabPages.Add(generalPage); PrimaryTab.Tag = this; PrimaryTabLayout = new FlowLayoutPanel(); PrimaryTabLayout.Parent = generalPage; PrimaryTabLayout.Left = 3; PrimaryTabLayout.Top = 3; PrimaryTabLayout.AutoScroll = true; PrimaryTabLayout.Width = generalPage.Width - 6; PrimaryTabLayout.Height = generalPage.Height - 6; PrimaryTabLayout.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; GroupBox groupBox = new GroupBox(); groupBox.Width = 350; groupBox.Height = 160; groupBox.Parent = PrimaryTabLayout; groupBox.Text = "System"; int newTop = 17; CreateLabel(groupBox, $"lblOSType{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblOSName{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lbl64BitOS{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblWinFolder{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblSysFolder{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblUptime{SafeServerName}", "Uptime:", 3, ref newTop, false); CreateLabel(groupBox, $"lblUpTimeValue{SafeServerName}", "u/k", 55, ref newTop, true); groupBox = new GroupBox(); groupBox.Width = 350; groupBox.Height = 160; groupBox.Parent = PrimaryTabLayout; groupBox.Text = "Processor"; newTop = 17; // Static Server Details CreateLabel(groupBox, $"lblProcessorType{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblProcessorSpeed{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblProcessorCores{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblProcessorProcessors{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblProcessorVirtualization{SafeServerName}", "u/k", 3, ref newTop, true); CreateLabel(groupBox, $"lblProcessorUtilizationDesc{SafeServerName}", "Utilization:", 3, ref newTop, false); CreateLabel(groupBox, $"lblProcessorUtilizationValue{SafeServerName}", "u/k", 70, ref newTop, true); CreateHeartBeat(groupBox, $"pnlHeartbeatProcessor{SafeServerName}", 270, 15, 70, 40, Color.OrangeRed, Color.Orange, "Current processor utilization"); // memory details groupBox = new GroupBox(); groupBox.Width = 350; groupBox.Height = 160; groupBox.Parent = PrimaryTabLayout; groupBox.Text = "Memory"; newTop = 17; CreateLabel(groupBox, $"lblMemoryPhysTot{SafeServerName}", "u/k", 3, ref newTop, true, "Total physical memory"); CreateLabel(groupBox, $"lblMemoryPhysAvail{SafeServerName}", "u/k", 3, ref newTop, true, "Total available physical memory"); CreateLabel(groupBox, $"lblMemoryPageTot{SafeServerName}", "u/k", 3, ref newTop, true, "Total page file size"); CreateLabel(groupBox, $"lblMemoryPageAvail{SafeServerName}", "u/k", 3, ref newTop, true, "Available page file size"); CreateLabel(groupBox, $"lblMemoryVirtTot{SafeServerName}", "u/k", 3, ref newTop, true, "Total virtual memory"); CreateLabel(groupBox, $"lblMemoryVirtAvail{SafeServerName}", "u/k:", 3, ref newTop, true, "Available virtual memory"); CreateLabel(groupBox, $"lblMemoryVirtExtended{SafeServerName}", "u/k", 3, ref newTop, true); CreateHeartBeat(groupBox, $"pnlHeartbeatMemory{SafeServerName}", 270, 15, 70, 40, Color.OrangeRed, Color.Orange, "Current memory usage"); CreateHeartBeat(groupBox, $"pnlHeartbeatPage{SafeServerName}", 270, 65, 70, 40, Color.DeepSkyBlue, Color.LightBlue, "Current page file usage"); // Dynamic Server Details newTop = groupBox.Top + groupBox.Height + 5; CreateLabel(generalPage, $"lblServiceMemory{SafeServerName}", "u/k", 3, ref newTop, true, "Total managed memory"); TabPage threadPage = new TabPage("Threads"); ServerTab.TabPages.Add(threadPage); ServerListView serverListView = new ServerListView(); serverListView.AutoSize = true; serverListView.Parent = "Threads"; serverListView.MessageName = $"{serverConnection.ServerName} {StringConstants.THREAD_USAGE}"; serverListView.ItemSeperator = ';'; serverListView.ColumnNames.Add("Name"); serverListView.ColumnNames.Add("Process CPU"); serverListView.ColumnNames.Add("System CPU"); serverListView.ColumnNames.Add("ID"); serverListView.ColumnNames.Add("Cancelled"); serverListView.ColumnNames.Add("Unresponsive"); serverListView.ColumnNames.Add("Removing"); client.AddListView($"{SafeServerName}_{StringConstants.THREAD_USAGE}", threadPage, serverListView); }
/// <summary> /// Display the server information in the listview. /// </summary> private void ShowServerInformation() { ListViewItem ServerListViewItem; try { ServerListView.BeginUpdate(); // Clear control ServerListView.Items.Clear(); // Initialize the server settings SqlServerSelection.Settings.Initialize(true); // Initialize the server information settings SqlServerSelection.Information.Initialize(true); // Initialize the server SqlServerSelection.Initialize(true); // Iterate through all the properties and add each one to the list foreach (Property prop in SqlServerSelection.Settings. Properties) { ServerListViewItem = ServerListView.Items.Add(prop. Name); ServerListViewItem.SubItems.Add(prop.Value == null ? string.Empty : prop.Value.ToString()); } // Iterate through all the properties and add each one to the list foreach (Property prop in SqlServerSelection.Properties) { ServerListViewItem = ServerListView.Items.Add(prop.Name); ServerListViewItem.SubItems.Add(prop.Value == null ? string.Empty : prop.Value.ToString()); } ServerListView.EndUpdate(); ConnectionListView.BeginUpdate(); // Clear control ConnectionListView.Items.Clear(); // Iterate through all the properties and add each one to the list foreach (Property prop in SqlServerSelection.Information.Properties) { ServerListViewItem = ConnectionListView.Items.Add( prop.Name); ServerListViewItem.SubItems.Add(prop.Value == null ? string.Empty : prop.Value.ToString()); } ConnectionListView.EndUpdate(); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
async Task LoadServers() { string oldText = Text; Text = Text + " (Loading Servers...)"; if (!string.IsNullOrWhiteSpace(MasterServerBox.Text)) { try { serverList.Clear(); Task info = await Task.Factory.StartNew(() => LoadServerInfoFromFile("http://" + MasterServerBox.Text + "/serverlist.txt")); Task.WaitAll(info); ServerListView.BeginUpdate(); ServerListView.Clear(); if (serverList.Count > 0) { var ColumnName = new ColumnHeader(); ColumnName.Text = "Name"; ColumnName.TextAlign = HorizontalAlignment.Center; ColumnName.Width = 284; ServerListView.Columns.Add(ColumnName); var ColumnClient = new ColumnHeader(); ColumnClient.Text = "Client"; ColumnClient.TextAlign = HorizontalAlignment.Center; ColumnClient.Width = 75; ServerListView.Columns.Add(ColumnClient); var ColumnVersion = new ColumnHeader(); ColumnVersion.Text = "Version"; ColumnVersion.TextAlign = HorizontalAlignment.Center; ColumnVersion.Width = 110; ServerListView.Columns.Add(ColumnVersion); foreach (var server in serverList) { var serverItem = new ListViewItem(server.ServerName); serverItem.UseItemStyleForSubItems = false; var serverClient = new ListViewItem.ListViewSubItem(serverItem, server.ServerClient); serverItem.SubItems.Add(serverClient); var serverVersion = new ListViewItem.ListViewSubItem(serverItem, server.ServerVersion); if (serverVersion.Text != GlobalVars.ProgramInformation.Version) { serverVersion.ForeColor = Color.Red; } serverItem.SubItems.Add(serverVersion); ServerListView.Items.Add(serverItem); } } else { MessageBox.Show("There are no servers available on this master server.", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ServerListView.EndUpdate(); } catch (Exception ex) { string message = "Unable to load servers (" + ex.GetBaseException().Message + ").\n\nMake sure you have a master server address other than 'localhost' in the textbox.\nIf the server still does not load properly, consult the administrator of the server for more information."; if (ex.GetBaseException().Message.Contains("404")) { message = "There are no servers available on this master server."; } GlobalFuncs.LogExceptions(ex); MessageBox.Show(message, "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ServerListView.Clear(); } finally { Text = oldText; } } }