public List <SServer> GetServerList() { var ls = new List <SServer>(); using (var con = GetConnection()) { using (var cmd = con.CreateCommand()) { cmd.CommandText = "SELECT * FROM server"; using (var r = cmd.ExecuteReader()) { while (r.Read()) { var server = new SServer { ID = r.GetUInt16("ID"), Type = r.GetByte("Type"), Name = r.GetString("Name"), PlayerLimit = r.GetUInt16("PlayerLimit"), IP = IPAddress.Parse(r.GetString("IP")), Port = r.GetUInt16("Port") }; ls.Add(server); } } } } return(ls); }
//public KdTree<float, Point> theTree = new KdTree<int, Point>(2, new IFloatMath()); #pragma warning disable CS0168 // Variable is declared but never used // Initialize private void Init() { server = new SServer(); Task.Factory.StartNew(() => { server.StartServer(); }); randGen = new Random(); singleEnt = new Entity(); props = new Props(); ents = new List <LinkedL>(); chrgs = new List <Charge>(); list = new List <int>(); listDead = new List <int>(); WIDTH = props.GetInt("WIDTH"); HEIGHT = props.GetInt("HEIGHT"); counter = props.GetInt("counter"); meatMax = props.GetInt("meatMax"); cntMeatLow = props.GetInt("cntMeatLow"); cntMeatHigh = props.GetInt("cntMeatHigh"); chrg_mod = props.GetInt("CHRG_RESPAWN_MOD"); treshold = props.GetInt("ENT_REP_TRESHOLD"); reproduction = props.GetInt("ENT_REP_AGE"); log = props.GetInt("SQLLOG") == 1 ? true : false; locked = false; watch = new Stopwatch(); hungry = props.GetInt("hungry"); fed = props.GetInt("fed"); }
public void Start() { try { SServer.Bind(EndPoint); } catch (Exception ex) { OnListenFailed(ex); return; } SServer.Listen(100); StartAccept(null); OnListenSucces(); }
protected void StartAccept(SocketAsyncEventArgs args) { if (args == null) { args = new SocketAsyncEventArgs(); args.Completed += AcceptEventCompleted; } else { args.AcceptSocket = null; } bool willRaiseEvent = SServer.AcceptAsync(args); if (!willRaiseEvent) { ProcessAccept(args); } }
public void Set(SServer Obj_) { base.Set(Obj_); EndTimes = Obj_.EndTimes; }
public SServer(SServer Obj_) : base(Obj_) { EndTimes = Obj_.EndTimes; }
public void Stop() { SServer.Shutdown(SocketShutdown.Both); }
public void Set(SServer Obj_) { base.Set(Obj_); }
public SServer(SServer Obj_) : base(Obj_) { }
public Dotnet(SocketIO client) { this.client = client; client.On("_visualizedependency", repo => { Task.Run(async() => { GithubRepository githubRepository = JsonConvert.DeserializeObject <GithubRepository>(repo.Text); if (githubRepository != null) { IServer _SServer = new SServer(new DbContext()); Console.WriteLine($"{githubRepository.full_name} Proje Bağımlılıkları Görüntüleme İşlemi Başladı."); Server server = _SServer.GetRandomServer(); if (server != null) { Console.WriteLine($"{githubRepository.full_name} Projesi {server.server_name} Sunucusunda İşlenecek!"); SshClient sshClient = null; if (Debugger.IsAttached) { sshClient = new SshClient(server.local_ip, server.local_port, "root", ""); } else { sshClient = new SshClient(server.remote_ip, server.remote_port, "root", ""); } using (sshClient) { try { sshClient.Connect(); SshCommand lsCommand = sshClient.CreateCommand("ls"); using (lsCommand) { lsCommand.Execute(); string message = lsCommand.Result; string[] bufferArr = message.Split('\n'); List <string> directories = new List <string>(bufferArr); directories.RemoveAll(x => String.IsNullOrEmpty(x)); if (directories.Contains(githubRepository.name)) { Console.WriteLine($"{githubRepository.full_name} {server.server_name} Sunucusunda Bulundu ve Silindi!"); SshCommand rmCommand = sshClient.CreateCommand($"rm -r {githubRepository.name}"); using (rmCommand) { rmCommand.Execute(); } } } SshCommand cloneCommand = sshClient.CreateCommand($"git clone {githubRepository.clone_url} && echo repository cloned"); using (cloneCommand) { cloneCommand.BeginExecute(); while (true) { Stream commandStream = cloneCommand.OutputStream; byte[] streamArr = new byte[commandStream.Length]; commandStream.Read(streamArr, 0, (int)commandStream.Length); string message = Encoding.ASCII.GetString(streamArr); if (message.Contains("repository cloned")) { Console.WriteLine($"{githubRepository.full_name} Projesi {server.server_name} Sunucusuna Başarıyla İndirildi!"); break; } Thread.Sleep(2000); } } SshCommand searchCommand = sshClient.CreateCommand($"find /root/{githubRepository.name}/ -name '*.csproj'"); using (searchCommand) { searchCommand.Execute(); string searchCommandResult = searchCommand.Result; string[] bufferArr = searchCommandResult.Split('\n'); List <string> csprojFiles = new List <string>(bufferArr); csprojFiles.RemoveAll(x => String.IsNullOrEmpty(x)); if (csprojFiles.Count > 0) { Console.WriteLine($"{githubRepository.full_name} Projesine Ait {csprojFiles.Count} Adet CSPROJ Dosyası Bulundu!"); SftpClient sftp = null; if (Debugger.IsAttached) { sftp = new SftpClient(server.local_ip, server.local_port, "root", ""); } else { sftp = new SftpClient(server.remote_ip, server.remote_port, "root", ""); } using (sftp) { sftp.Connect(); SocketEntity socketEntity = new SocketEntity(); foreach (string csprojfile in csprojFiles) { string[] csprojArr = csprojfile.Split('/'); string projectName = (csprojArr[csprojArr.Length - 1]).Replace(".csproj", ""); string fileName = Guid.NewGuid().ToString() + ".csproj"; string path = Directory.GetCurrentDirectory() + $"/{fileName}"; using (Stream stream = File.Create(path)) { sftp.DownloadFile(csprojfile, stream); } if (File.Exists(path)) { string csprojContent = File.ReadAllText(path); File.Delete(path); Project project = null; using (var stringReader = new System.IO.StringReader(csprojContent)) { var serializer = new XmlSerializer(typeof(Project)); project = serializer.Deserialize(stringReader) as Project; } if (project != null) { SocketEntity.Project socketProject = new SocketEntity.Project(); socketProject.name = projectName; socketProject.sdk = project.Sdk; foreach (ItemGroup itemGroup in project.ItemGroup) { if (itemGroup.PackageReference.Count > 0) { List <SocketEntity.Reference> references = itemGroup.PackageReference.Select(x => new SocketEntity.Reference { include = x.Include, includeType = (int)enumIncludeType.package, version = x.Version }).ToList(); socketProject.references.AddRange(references); } if (itemGroup.ProjectReference.Count > 0) { foreach (ProjectReference projectReference in itemGroup.ProjectReference) { string include = projectReference.Include; string[] includeArr = include.Split('\\'); include = (includeArr[includeArr.Length - 1]).Replace(".csproj", ""); socketProject.references.Add(new SocketEntity.Reference { include = include, includeType = (int)enumIncludeType.project, version = "" }); } } } foreach (PropertyGroup propertyGroup in project.PropertyGroup) { if (!String.IsNullOrEmpty(propertyGroup.TargetFramework)) { socketProject.targetFramework = propertyGroup.TargetFramework; } if (!String.IsNullOrEmpty(socketProject.targetFramework)) { break; } } socketEntity.projects.Add(socketProject); } else { Console.WriteLine($"{githubRepository.full_name} CSPROJ Dosyası Okunamadı!"); return; } } else { Console.WriteLine($"{githubRepository.full_name} CSPROJ Dosyası İndirilemedi!"); return; } } Console.WriteLine($"{githubRepository.full_name} Projesi Başarıyla İşlendi!"); client.EmitAsync("showDependency", githubRepository, socketEntity).Wait(); } } else { Console.WriteLine($"{githubRepository.full_name} Reposuna Ait Bir CSPROJ Dosyası Bulunamadı!"); return; } } } catch (Exception ex) { Console.WriteLine($"{ex.Message}"); } } } else { Console.WriteLine("Aktif Bir Sunucu Bulunamadı!"); return; } } else { Console.WriteLine("Hatalı Bir Veri Geldi!"); return; } }); }); }
public SDuChildOn(SServer Super_, TSessionCode SessionCode_, SNamePort ChildBindNamePort_) : base(Super_) { SessionCode = SessionCode_; ChildBindNamePort = ChildBindNamePort_; }
public SUdParentOn(SServer Super_, TPeerCnt ChildCntMax_, TPeerCnt ErrorCnt_) : base(Super_) { ChildCntMax = ChildCntMax_; ErrorCnt = ErrorCnt_; }
public void Set(SServer Obj_) { ClientBindNamePortPub.Set(Obj_.ClientBindNamePortPub); Capacity.Set(Obj_.Capacity); }
public SServer(SServer Obj_) { ClientBindNamePortPub = Obj_.ClientBindNamePortPub; Capacity = Obj_.Capacity; }
protected async override Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { Console.WriteLine("Server Worker Çalıştırıldı!"); IServer _SServer = new SServer(new DbContext()); List <Server> servers = _SServer.GetServers(); foreach (Server server in servers) { server.status_id = (int)enumStatus.Pasif; if (_SServer.UpdateServer(server)) { Console.WriteLine($"{server.server_name} Sunucusu Pasif Duruma Güncellendi!"); if (Debugger.IsAttached) { Thread.Sleep((int)TimeSpan.FromSeconds(10).TotalMilliseconds); } else { Thread.Sleep((int)TimeSpan.FromMinutes(10).TotalMilliseconds); } SshClient sshClient = null; if (Debugger.IsAttached) { sshClient = new SshClient(server.local_ip, server.local_port, "root", "03102593"); } else { sshClient = new SshClient(server.remote_ip, server.remote_port, "root", "031002593"); } try { using (sshClient) { sshClient.Connect(); SshCommand lsCommand = sshClient.CreateCommand("ls"); lsCommand.Execute(); string lsCommandResult = lsCommand.Result; string[] bufferArr = lsCommandResult.Split('\n'); List <string> directories = new List <string>(bufferArr); directories.RemoveAll(x => String.IsNullOrEmpty(x)); foreach (string directory in directories) { SshCommand rmCommand = sshClient.CreateCommand($"rm -r {directory}"); rmCommand.Execute(); } server.status_id = (int)enumStatus.Aktif; if (_SServer.UpdateServer(server)) { Console.WriteLine($"{server.server_name} Sunucusu Aktif Duruma Başarıyla Güncellendi!"); } else { Console.WriteLine($"{server.server_name} Sunucusu Aktif Duruma Güncellenemedi!"); } } } catch (Exception ex) { Console.WriteLine($"{ex.Message}"); } } else { Console.WriteLine($"{server.server_name} Sunucusu Pasif Duruma Güncellenemedi!"); } } if (Debugger.IsAttached) { await Task.Delay((int)TimeSpan.FromSeconds(30).TotalMilliseconds, stoppingToken); } else { await Task.Delay((int)TimeSpan.FromDays(1).TotalMilliseconds, stoppingToken); } } }