예제 #1
0
        static void Main(string[] args)
        {
            // Set log mode
            LogTextWriter.InitLogMode();
            // Start listener
            var srv = new OTcpServer(1010);
            // Create server instance
            var impl = new ServerLogicImplementation();

            // Register server implementation
            srv.RegisterImplementation(impl);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"The {Process.GetCurrentProcess().ProcessName} start");
            Console.WriteLine("Write message nad press Enter key to send notifications");
            Console.ResetColor();
            while (true)
            {
                var msg = Console.ReadLine();
                foreach (var client in impl.Subscribes)
                {
                    client.Notify(msg);
                }
                Console.WriteLine($"{impl.Subscribes.Count} notification{(impl.Subscribes.Count > 1 ? "s" : "")}");
            }
        }