static void Main(string[] args)
        {
            server.Start();

            if (args.Length == 0)
            {
                System.Console.WriteLine("podaj scieżkę do pliku z pozycjami cymbalistow...");
                return;
            }
            System.Console.WriteLine("Gdy na konsoli się pojawią informacje typu");
            System.Console.WriteLine("[jankiel1] subscribe [jankiel2]");
            System.Console.WriteLine("Nalezy wcisnąć ENTER by wysłać wiadomość od 'Mastera'");
            System.Console.WriteLine("poinformowania cymbalistów by rozpoczeli działanie");
            var positions = Helpers.GetPositions(args[0]);

            int D = 0;

            for (int i = 0; i < positions.GetLength(0); i++)
            {
                var name      = Helpers.GetJankielName(positions[i]);
                var neighbors = Helpers.GetNeighborsForI(positions, i, Settings.Default.HearDistance);
                if (D < neighbors.Length)
                {
                    D = neighbors.Length;
                }

                new Thread(new ThreadStart(new Jankiel.Jankiel(name, neighbors).Run)).Start();
            }
            var Master = new MqttFactory().CreateMqttClient();

            Master.Connected += (s, e) =>
            {
                System.Console.WriteLine("Master Connected");
            };
            Master.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("localhost", 1884).Build());

            var msg   = new StartExMessage(D * 2, 5, positions.GetLength(0)).GetBytes();
            var mqMsg = new MqttApplicationMessageBuilder().WithTopic("Ex3Master").WithPayload(msg).Build();

            System.Console.WriteLine("enter by wysłac wiadomosc od mastera");
            System.Console.ReadLine();

            Master.PublishAsync(mqMsg);
            System.Console.WriteLine("enter by zakonczyc");
            System.Console.ReadLine();
            server.Stop();
        }
Exemple #2
0
 internal void ProcessStartExMessage(StartExMessage startExMessage)
 {
     FirstMISForLength  = (int)Math.Log(startExMessage.D);
     SecondMISForLength = startExMessage.M * (int)Math.Log(startExMessage.n);
     StartJankiel();
 }