Exemple #1
0
 private void Client_OnSoftwareIDRecieved(object sender, STDLib.JBVProtocol.IO.Frame e)
 {
     lock (Servers)
     {
         TileServer server = Servers.FirstOrDefault(a => a.ID == e.SID);
         if (server == null)
         {
             Servers.Add(server = new TileServer()
             {
                 ID = e.SID
             });
         }
     }
 }
Exemple #2
0
        void ProcessCommand(TileBaseCmd command)
        {
            switch (command)
            {
            case TileCMD_GetServername cmd:

                lock (Servers)
                {
                    TileServer server = Servers.FirstOrDefault(a => a.ID == cmd.SID);
                    if (server != null)
                    {
                        if (server.Name != cmd.Servername)
                        {
                            server.Name = cmd.Servername;
                            OnServerFound?.Invoke(this, server);
                        }
                    }
                }
                break;

            case TileCMD_GetMapInfo cmd:
                OnMapInfoRecieved?.Invoke(this, cmd.MapInfo);
                break;

            case TileCMD_UpdatePlayerInfo cmd:
                lock (Players)
                {
                    PlayerInfo pi = Players.FirstOrDefault(p => p.ID == cmd.Playerinfo.ID);
                    if (pi == null)
                    {
                        Players.Add(pi = new PlayerInfo()
                        {
                            ID = cmd.Playerinfo.ID
                        });
                    }
                    pi.Populate(cmd.Playerinfo);
                }
                break;
            }
        }
Exemple #3
0
 public void ConnectToServer(TileServer server)
 {
     SelectedServer = server;
 }
Exemple #4
0
 private void MapClient_OnServerFound(object sender, TileServer e)
 {
     listBox1.InvokeIfRequired(() => listBox1.Items.Add(e));
 }