public PingServerFixture() { _httpForm = new Mock <IHttpForm>(); _eventAggregator = new Mock <IEventAggregator>(); _pingServer = new PingServer(settings.Object, _eventAggregator.Object, _httpForm.Object, "http://rpc.testserver.com", 30); }
private static async void AliveServer(string ip, int port) { try { await Task.Run(() => { PingServer server = new PingServer(ip, port); }); } catch (Exception e) { log.Error($"Error: {e.Message}"); } }
/// <summary> /// Ping microservizio (monitoring) /// </summary> /// <param name="ip"></param> /// <param name="port"></param> private static async void AliveServer(string ip, int port) { try { await Task.Run(() => { PingServer server = new PingServer(ip, port); }); } catch (Exception e) { log.ErrorFormat("!ERROR: {0}", e.ToString()); } }
public StartupTestFixture() { AppSettings = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddXmlFile("appsettings.Test.xml", optional: true, reloadOnChange: false) .AddEnvironmentVariables() .AddEnvironmentVariables("Lactalis_") .AddEnvironmentVariables($"Lactalis_Test_") .Build(); //load in site configuration var siteConfiguration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddIniFile("SiteConfig.ini", optional: true, reloadOnChange: false) .Build(); SiteSettings = new SiteSettings(); siteConfiguration.GetSection("site").Bind(SiteSettings); //load in the user configurations UserSettings = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddIniFile("UserConfig.ini", optional: true, reloadOnChange: false) .Build(); var superUserSettings = new UserSettings(); var testUserSettings = new UserSettings(); UserSettings.GetSection("super").Bind(superUserSettings); UserSettings.GetSection("test").Bind(testUserSettings); var baseUrlFromEnvironment = Environment.GetEnvironmentVariable("BASE_URL"); BaseUrl = baseUrlFromEnvironment ?? SiteSettings.BaseUrl; TestUsername = testUserSettings.Username; TestPassword = testUserSettings.Password; SuperUsername = superUserSettings.Username; SuperPassword = superUserSettings.Password; var dbConnectionString = AppSettings["ConnectionStrings:DbConnectionString"]; DbContextOptions = new DbContextOptionsBuilder<LactalisDBContext>() .UseNpgsql(dbConnectionString) .Options; PingServer.TestConnection(BaseUrl); using (var context = new LactalisDBContext(DbContextOptions, null, null)) { SuperOwnerId = context.Users.First(x => x.UserName == SuperUsername).Id; } }
public static void Main(string[] args) { Server server = new Server { Services = { PingServer.BindService(new GreeterImpl()) }, Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Greeter server listening on port " + Port); Console.WriteLine("Press any key to stop the server..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public static void Main(string[] args) { Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure); var client = PingServer.NewClient(channel); String user = "******"; var reply = client.Hello(new HelloRequest { Message = user }); Console.WriteLine("Greeting: " + reply.Message); channel.ShutdownAsync().Wait(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
public void Serialize(XmlWriter writer) { writer.WriteStartElement("Region"); writer.WriteAttributeString("regionName", Name); PingServer.Serialize(writer, "PingServer"); writer.WriteStartElement("LoginServerList"); foreach (var server in LoginServers) { server.Serialize(writer, "LoginServer"); } writer.WriteEndElement(); //LoginServerList writer.WriteEndElement(); //Region }
/// <summary> /// This method checks if there is a valid IP for a local server saved in memory. It uses the <see cref="PingServer"/> class to /// verify if a stored IP address is still valid. /// </summary> /// <returns><c>True</c>, if the server could be verified, <c>False</c> otherwise.</returns> public static bool IsServerValid(string defaultIP) { if (defaultIP == null) { return(false); } try { string address = strings.defaultPrefix + defaultIP + ":" + int.Parse(strings.defaultPort); bool validIp = PingServer.Check(address); } catch (Exception ex) // Not only catch ServerException, but also Exceptions that could be thrown following an invalid Parse. { Console.WriteLine(ex); return(false); } return(true); }
static void Mainasdfasdfasdf(string[] args) { var serversList = new List <StratumConnection> { //groestl - StratumConnection.Parse("hub.miningpoolhub.com,12004,wchasik,home,x"); //myr-gr - StratumConnection.Parse("hub.miningpoolhub.com,12005,wchasik,home,x"); StratumConnection.Parse(AlgoNiceHashEnum.X11, "hub.miningpoolhub.com,12007,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.X13, "hub.miningpoolhub.com,12008,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.X15, "hub.miningpoolhub.com,12009,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.NeoScrypt, "hub.miningpoolhub.com,12012,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.Qubit, "hub.miningpoolhub.com,12014,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.Quark, "hub.miningpoolhub.com,12015,wchasik,home,x"), // skein - StratumConnection.Parse("hub.miningpoolhub.com,12016,wchasik,home,x"); StratumConnection.Parse(AlgoNiceHashEnum.Lyra2REv2, "hub.miningpoolhub.com,12018,wchasik,home,x"), // vanilla - StratumConnection.Parse("hub.miningpoolhub.com,12019,wchasik,home,x"); StratumConnection.Parse(AlgoNiceHashEnum.DaggerHashimoto, "europe.ethash-hub.miningpoolhub.com,12020,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.Equihash, "europe.equihash-hub.miningpoolhub.com,12023,wchasik,home,x"), StratumConnection.Parse(AlgoNiceHashEnum.CryptoNight, "europe.cryptonight-hub.miningpoolhub.com,12024,wchasik,home,x") }; serversList.Where(sc => sc.Algo == AlgoNiceHashEnum.NeoScrypt || sc.Algo == AlgoNiceHashEnum.Equihash || sc.Algo == AlgoNiceHashEnum.CryptoNight || sc.Algo == AlgoNiceHashEnum.Lyra2REv2) .ToList().ForEach(server => { var pinger = new PingServer(server, 10000); pinger.PingResultChanged += result => { //System.Console.BackgroundColor = result.Success ? ConsoleColor.Cyan : ConsoleColor.Red; System.Console.WriteLine($"minutes: {(DateTime.Now - result.DateTime).TotalMinutes:#######.##} ; {result.Success} ; {result.Result}"); }; pinger.GotResponse += (sender, stratumEventArgs) => { }; }); System.Console.ReadLine(); }
/// <summary> /// Determine if the next screen should be loaded. Server discovery should always be loaded. /// The devices main screen should only be loaded if the Server is valid. /// </summary> /// <param name="segueIdentifier"></param> /// <param name="sender"></param> /// <returns></returns> public override bool ShouldPerformSegue(string segueIdentifier, NSObject sender) { if (segueIdentifier == strings.segueToServerDiscovery) { return(true); } bool validIp = false; try { string address = strings.defaultPrefix + newIP.Text + ":" + int.Parse(strings.defaultPort); validIp = PingServer.Check(address); } catch (Exception ex) { Console.WriteLine(ex); WarningMessage.Display("Could not connect to server", "Invalid server information", this); connectButton.Selected = false; return(false); } if (validIp) { Globals.ServerName = newServerName.Text; Globals.Address = strings.defaultPrefix + newIP.Text + ":" + strings.defaultPort; HestiaServerInteractor serverInteractor = new HestiaServerInteractor(new NetworkHandler(Globals.Address)); Globals.LocalServerinteractor = serverInteractor; userDefaults.SetString(newServerName.Text, strings.defaultsServerNameHestia); userDefaults.SetString(newIP.Text, strings.defaultsIpHestia); return(true); } WarningMessage.Display("Could not connect to server", "Invalid server information", this); connectButton.Selected = false; return(false); }