Exemplo n.º 1
0
 private void populateList(Action <List <FarmHubServer> > callback = null)
 {
     if (client == null)
     {
         client = new FirebaseClient(farmHub);
     }
     Task.Run(async() =>
     {
         var servers = await farms.OnceAsync <FarmHubServer>();
         farmHubServers.Clear();
         foreach (var server in servers)
         {
             int cTime         = (Int32)(DateTime.UtcNow.Subtract(new DateTime(2018, 1, 1))).TotalSeconds;
             FarmHubServer fhs = server.Object;
             if (cTime - fhs.LastUpdate >= 60)
             {
                 Task.Run(() => farms.Child(fhs.Id).DeleteAsync());
             }
             else
             {
                 farmHubServers.Add(server.Object);
             }
             callback?.Invoke(farmHubServers);
         }
     });
 }
Exemplo n.º 2
0
        private void StartFarmHubServer(object sender, EventArgs e)
        {
            if (Game1.IsServer)
            {
                if (client == null)
                {
                    client = new FirebaseClient(farmHub);
                }

                if (myServer == null)
                {
                    Task.Run(() => waitForServerConnection(() => {
                        Monitor.Log("InviteCode:" + Game1.server.getInviteCode());
                        Monitor.Log("IP:" + FarmHubServer.GetLocalIPAddress());
                        myServer = new FarmHubServer(Game1.server, Monitor);
                        Monitor.Log("Joining Farmhub", LogLevel.Info);
                    }));
                }
            }
            else
            if (myServer is FarmHubServer fsh)
            {
                fsh.Dispose();
            }
        }
Exemplo n.º 3
0
 private void writeListToConsole(List <FarmHubServer> list)
 {
     Monitor.Log("---------|FarmHub|---------", LogLevel.Info);
     if (list.Count == 0)
     {
         Monitor.Log("No Server available", LogLevel.Error);
         Monitor.Log("---------------------------", LogLevel.Info);
     }
     for (int i = 0; i < list.Count; i++)
     {
         FarmHubServer f = list[i];
         Monitor.Log($"{i} : {f.Name} ({f.CurrentPlayers}/{f.MaxPlayers}) [{ (f.Password == open ? "open" : "pw") }]", LogLevel.Info);
         bool hMods = hasMods(f.RequiredMods);
         Monitor.Log("Required Mods: " + string.Join(",", f.RequiredMods), hMods ? LogLevel.Info : LogLevel.Error);
         Monitor.Log("---------------------------", LogLevel.Info);
     }
 }