Exemplo n.º 1
0
        public void SendNetworkShift(SatelliteClient sc)
        {
            string shiftResult = Utilities.SerializeSatelliteClient(sc);

            clientsToDump.Enqueue(sc);
            Clients.All.ProcessUpdate(shiftResult);
        }
Exemplo n.º 2
0
 public static void AddSatellite(SatelliteClient sc)
 {
     if (!satellites.Contains(sc))
     {
         satellites.Add(sc);
     }
 }
Exemplo n.º 3
0
 private void ArchiveClientUpdate(SatelliteClient sc, string data)
 {
     if (sc != null && !string.IsNullOrEmpty(data))
     {
         string type = sc.SatelliteName + Enumerations.UpdateType._ClientUpdate_.ToString() + DateTime.Now.ToString(PlanetConstants.ARCHIVE_UPDATE_DATE_FORMAT);
         db.InsertUpdate(type, data);
     }
 }
Exemplo n.º 4
0
        public static SatelliteClient DeserializeSatelliteClient(string serializedValue)
        {
            SatelliteClient sc = null;

            sc = JsonConvert.DeserializeObject <SatelliteClient>(serializedValue);

            return(sc);
        }
Exemplo n.º 5
0
        public static string SerializeSatelliteClient(SatelliteClient sc)
        {
            string serializedValue = string.Empty;

            serializedValue = JsonConvert.SerializeObject(sc);

            return(serializedValue);
        }
Exemplo n.º 6
0
        public void RegisterSatellite(string status)
        {
            Status s = Utilities.DeserializeStatus(status);

            if (!satellites.Exists(x => x.SatelliteName.Equals(s.SatelliteName)))
            {
                SatelliteClient sc = new SatelliteClient(s.SatelliteName, s.onStation, s.solarPanelsDeployed);

                clientsToDump.Enqueue(sc);
                satellites.Add(sc);
                NetworkShiftThread.AddSatellite(sc);
            }
        }
Exemplo n.º 7
0
        private void ProcessUpdate(string result)
        {
            SatelliteClient sc = Utilities.DeserializeSatelliteClient(result);

            if (sc.SatelliteName.Equals(this.SatelliteStatus.SatelliteName))
            {
                this.SatelliteStatus.onStation           = sc.Onstation;
                this.SatelliteStatus.solarPanelsDeployed = sc.SolarPanelsDeployed;
                this.SatelliteStatus.PlanetShift         = sc.PlanetShift;
                this.SatelliteStatus.DestinationX        = sc.DestinationX;
                this.SatelliteStatus.DestinationY        = sc.DestinationY;
            }
        }
Exemplo n.º 8
0
        public void UpdateSatellite(SatelliteClient sc)
        {
            SatelliteClient curSc = satellites.Find(x => x.SatelliteName.Equals(sc.SatelliteName));

            if (curSc != null)
            {
                curSc.SatelliteName       = sc.SatelliteName;
                curSc.Onstation           = sc.Onstation;
                curSc.SolarPanelsDeployed = sc.SolarPanelsDeployed;
                curSc.PlanetShift         = sc.PlanetShift;
                curSc.DestinationX        = sc.DestinationX;
                curSc.DestinationY        = sc.DestinationY;
            }
        }
Exemplo n.º 9
0
        public void UpdateClients(Status s)
        {
            SatelliteClient sc = satellites.Find(x => x.SatelliteName.Equals(s.SatelliteName));

            if (sc != null)
            {
                sc.SatelliteName       = s.SatelliteName;
                sc.Onstation           = s.onStation;
                sc.SolarPanelsDeployed = s.solarPanelsDeployed;
                sc.PlanetShift         = s.PlanetShift;
                sc.DestinationX        = s.DestinationX;
                sc.DestinationY        = s.DestinationY;

                shiftThread.UpdateSatellite(sc);
            }
        }
Exemplo n.º 10
0
        private void ArchiveClientData(int count)
        {
            int ctr = 0;                                                            //hack

            while (ctr < count)
            {
                if (PlanetServerHub.clientsToDump.Count < 1)                        //hack
                {
                    break;
                }

                SatelliteClient sc     = PlanetServerHub.clientsToDump.Dequeue();
                string          status = Utilities.SerializeSatelliteClient(sc);
                ArchiveClientUpdate(sc, status);
                ctr++;                                                              //hack
            }
        }