Exemplo n.º 1
0
        public bool RemoveServer(ServerListing serverListing)
        {
            int serverIndex = _servers.FindIndex(x => x.IP == serverListing.IP && x.Port == serverListing.Port);

            if (serverIndex != -1)
            {
                _servers.RemoveAt(serverIndex);
                _logger.LogInformation($"Server {serverListing.Name} {serverListing.IP}:{serverListing.Port} removed");
                return(true);
            }
            return(false);
        }
    private void Awake()
    {
        //connectionConfig.MaxSentMessageQueueSize = 2048;
        //connectionConfig.MaxCombinedReliableMessageCount = 20;

        //Debug.Log("It's Alive! (ArsNetworkManager.cs)");
        useWebSockets = true;
        ServerListing =
            ServerListing.FromWebJSON(
                "https://docs.google.com/document/d/1LLT3FxiRC-NoI6OnRHlMUSd5O1_I4zB-ABDR4-wCNp0/export?format=txt");
        Debug.Log("Server Count: " + ServerListing.Servers.Length);
    }
Exemplo n.º 3
0
        public IActionResult RegisterServer([FromBody] ServerListing serverListing)
        {
            if (string.IsNullOrEmpty(serverListing.Name))
            {
                return(BadRequest("Invaild server details"));
            }

            serverListing.IP = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            _masterServerListService.AddServer(serverListing);

            return(Ok());
        }
Exemplo n.º 4
0
        public static void PopulateList()
        {
            for (int i = 0; i < List.Count / 4; i++)
            {
                ServerListing listing = new ServerListing();
                listing.lServerAddress.Text = $"{List[i].ip}:{List[i].port}";
                listing.lServerLatency.Text = $"{ServerLatency(List[i].ip)}ms";
                listing.Width = windowMain.pServerList.Width - 25;

                if (listing.lServerLatency.Text != "--ms")
                {
                    windowMain.pServerList.Controls.Add(listing);
                }
            }
        }
Exemplo n.º 5
0
        public void AddServer(ServerListing serverListing)
        {
            serverListing.LastUpdate = DateTime.Now;

            int existingListingIndex = _servers.FindIndex(x => x.IP == serverListing.IP && x.Port == serverListing.Port);

            if (existingListingIndex == -1)
            {
                _servers.Add(serverListing);
                _logger.LogInformation($"New server registered {serverListing.Name} {serverListing.IP}:{serverListing.Port}");
            }
            else
            {
                _servers[existingListingIndex] = serverListing;
                _logger.LogInformation($"Server updated {serverListing.Name} {serverListing.IP}:{serverListing.Port}");
            }
        }
Exemplo n.º 6
0
 public IActionResult UnregisterServer([FromBody] ServerListing serverListing)
 {
     serverListing.IP = Request.HttpContext.Connection.RemoteIpAddress.ToString();
     return(_masterServerListService.RemoveServer(serverListing) ? Ok("Removed the server.") : BadRequest("Failed to remove the server"));
 }