コード例 #1
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                LinksServerStoped = true;
            };

            var links = new CoreNet.Pairs.Links();

            //InitUTF16(links);

            PrintContents(links);

            //var sequences = new Sequences(links);

            Console.WriteLine("Links slave server started.");

            using (var sender = new UdpSender(8888))
            {
                using (var receiver = new UdpReceiver(7777, m =>
                {
                    Console.WriteLine("R.M.: {0}", m);

                    if (!string.IsNullOrWhiteSpace(m))
                    {
                        if (m.EndsWith("?"))
                        {
                            m = m.Remove(m.Length - 1);
                            //sequences.Search(sender, m);
                        }
                    }
                }))
                {
                    receiver.Start();

                    while (!LinksServerStoped) Thread.Sleep(1);

                    receiver.Stop();
                }
            }

            Console.WriteLine("Links slave server stopped.");
        }
コード例 #2
0
        private static void Main()
        {
            using (var receiver = new UdpReceiver(8888, m => Console.WriteLine("R.M.: {0}", m)))
            {
                receiver.Start();

                using (var sender = new UdpSender(7777))
                {
                    Console.WriteLine("Welcome to sequences terminal.");

                    string line;
                    while (!string.IsNullOrWhiteSpace(line = Console.ReadLine()))
                        sender.Send(line);

                    Console.WriteLine("Empty request. Press any key to terminate process.");
                    Console.ReadKey();
                }

                receiver.Stop();
            }

            Console.WriteLine();
            Console.ReadKey();
        }
コード例 #3
0
        private static void Main()
        {
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                LinksServerStoped = true;
            };

            File.Delete(DefaultDatabaseFilename);

            using (var links = new CoreUnsafe.Pairs.Links(DefaultDatabaseFilename, 512 * 1024 * 1024))
            {
                InitUTF16(links);

                PrintContents(links);

                var sequences = new Sequences(links);

                Console.WriteLine("Links server started.");
                Console.WriteLine("Press CTRL+C to stop server.");

                using (var sender = new UdpSender(8888))
                {
                    using (var receiver = new UdpReceiver(7777, m =>
                    {
                        Console.WriteLine("R.M.: {0}", m);

                        if (!string.IsNullOrWhiteSpace(m))
                        {
                            if (m.EndsWith("?"))
                            {
                                m = m.Remove(m.Length - 1);
                                sequences.Search(sender, m);
                            }
                            else
                                sequences.Create(sender, m);
                        }
                    }))
                    {
                        receiver.Start();

                        while (!LinksServerStoped) Thread.Sleep(1);

                        receiver.Stop();
                    }
                }

                Console.WriteLine("Links server stopped.");
            }
        }