private static void station_join(string station, string content) { if (String.IsNullOrEmpty(content)) { return; } StationConfig cfg; try { cfg = JsonConvert.DeserializeObject <StationConfig>(content); } catch (Exception e) { LogRecorder.Exception(e); return; } cfg.State = StationState.Run; if (StationProgram.Configs.ContainsKey(station)) { StationProgram.Configs[station] = cfg; } else { StationProgram.Configs.Add(station, cfg); } if (StationProgram.Stations.ContainsKey(station)) { StationProgram.Stations[station].Config = cfg; StationProgram.WriteLine($"{station} is join"); StationEvent?.Invoke(cfg, new StationEventArgument("station_join", cfg)); ZeroStation.Run(StationProgram.Stations[station]); } }
/// <summary> /// Ö´ÐÐ /// </summary> /// <param name="station"></param> public static void Run(ZeroStation station) { station.Close(); station.Config = StationProgram.GetConfig(station.StationName); if (station.Config == null) { StationProgram.WriteLine($"{station.StationName} not find,try install..."); StationProgram.InstallApiStation(station.StationName); return; } station.Run(); }
private static void system_start(string content) { StationProgram.WriteLine(content); StationProgram.Configs.Clear(); StationEvent?.Invoke(null, new StationEventArgument("system_start", null)); foreach (var sta in StationProgram.Stations.Values) { StationProgram.WriteLine($"Restart {sta.StationName}"); ZeroStation.Run(sta); StationEvent?.Invoke(sta, new StationEventArgument("station_join", sta.Config)); } }
private static void station_resume(string station, string content) { if (StationProgram.Configs.TryGetValue(station, out var cfg)) { cfg.State = StationState.Run; } if (StationProgram.Stations.ContainsKey(station)) { StationProgram.WriteLine($"{station} is resume"); ZeroStation.Run(StationProgram.Stations[station]); } StationEvent?.Invoke(cfg, new StationEventArgument("station_resume", cfg)); }