static void Main(string[] args) { ILoggable logger = new BLog.Builder() .WithConsole(true) .WithFilter(LogFilter.All) .Build(); logger.info("Hello, Bryllite!"); using (CancellationTokenSource cts = new CancellationTokenSource()) { Console.CancelKeyPress += (sender, e) => { e.Cancel = true; cts.Cancel(); }; TestTcpServer server = new TestTcpServer(logger); server.Start(TcpHelper.ANY, PORT); while (!cts.IsCancellationRequested) { Thread.Sleep(10); } server.Stop(); } logger.info("Bye, Bryllite!"); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); ILoggable logger = new BLog.Builder() .WithConsole(true) .WithFilter(LogFilter.All) .Build(); using (CancellationTokenSource cts = new CancellationTokenSource()) { Console.CancelKeyPress += (sender, e) => { e.Cancel = true; cts.Cancel(); }; while (!cts.IsCancellationRequested) { // Thread.Sleep(100); Payload payload = new Payload.Builder() .Value("rndBytes", RndProvider.GetNonZeroBytes(MessageLength)) .Build(); TcpClient.SendTo("127.0.0.1", PORT, payload.ToBytes()); } } }
static void Main(string[] args) { // load Configuration IConfiguration Configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(APPSETTINGS, optional: true, reloadOnChange: true) .Build(); // logger ILoggable Logger = new BLog.Builder() .WithConsole(true) .WithLogger(new RotateFileLogger(Configuration.GetValue("Logging:LogFileName", "PeerListServiceApp.log"))) .Global(true) .WithFilter(LogFilter.All) .Build(); Logger.info($"Hello, Bryllite!"); // node map provider IPeerList peers = new PeerList(Logger); using (var cts = new CancellationTokenSource()) { PeerListService server = new PeerListService(Configuration.GetSection("PeerListService"), Logger, peers); server.Start(32, cts); // garbage collection //System.Timers.Timer gcTimer = new System.Timers.Timer(30 * 1000); //gcTimer.Elapsed += OnGarbageCollect; //gcTimer.Enabled = true; Console.CancelKeyPress += (sender, e) => { e.Cancel = true; cts.Cancel(); }; while (!cts.Token.IsCancellationRequested) { Thread.Sleep(10); server.Update(); } server.Stop(); } Logger.info($"Bye, Bryllite!"); }
static void Main(string[] args) { ILoggable logger = new BLog.Builder() .WithConsole(true) .WithFilter(LogFilter.All) .Build(); PrivateKey key = PrivateKey.CreateKey(); using (CancellationTokenSource cts = new CancellationTokenSource()) { NodeServer server = new NodeServer(logger); server.Start(PORT, cts); Console.CancelKeyPress += (sender, e) => { e.Cancel = true; cts.Cancel(); }; byte[] rndBytes = RndProvider.GetNonZeroBytes(1024 * 1024); while (!cts.IsCancellationRequested) { Thread.Sleep(10); rndBytes = RndProvider.GetNonZeroBytes(1024 * 1024); Message message = new Message.Builder() .Body("rndBytes", rndBytes) .Build(key); byte[] data = message.ToBytes(); // ElasticNode.SendTo(data, "127.0.0.1", PORT); NodeClient client = new NodeClient(logger); client.Start("127.0.0.1", PORT); Thread.Sleep(1000); // client.Write(data); client.Stop(); } } }