예제 #1
0
    void Start()
    {
        _komunikat = GameObject.Find("Komunikat_Kursor").GetComponent <Komunikat>();

        if (Komunikat == null || Komunikat == "")
        {
            Komunikat = "Przykladowy Komunikat";
        }

        _bJuzPoszedl = true;

        Init_Delegates
        (
            Obiekt_Klik_Lewy,
            Obiekt_KlikDown_Lewy,
            Obiekt_KlikUp_Lewy,

            Obiekt_Klik_Prawy,
            Obiekt_KlikDown_Prawy,
            Obiekt_KlikUp_Prawy,

            Obiekt_Hover,
            Obiekt_Leave,

            Global_CoursorContact,
            Global_CoursorContactWithThis,
            Global_CoursorContactWithOther,
            Global_CoursorNoContact
        );
    }
예제 #2
0
        void SendMessage(string message)
        {
            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri("rabbitmq://*****:*****@hound.rmq.cloudamqp.com/luozycyv"),
                                    h => { });

                sbc.ReceiveEndpoint(host, "answerqueue", ep =>
                {
                    ep.Handler <Komunikat>(Handle);
                });
            });

            bus.Start();



            var Release = new Komunikat()
            {
                Tekst = message,
                Dzien = DateTime.Now
            };

            bus.Publish <Komunikat>(Release);
            System.Threading.Thread.Sleep(3000);
            bus.Stop();
        }
예제 #3
0
        public string serializacja(string imageName, bool hq)
        {
            var komunikat = new Komunikat(imageName, listaProcesow, listaStron, hq);
            var json      = new JavaScriptSerializer().Serialize(komunikat);

            return(json);
        }
예제 #4
0
 public void DodajTekst(Komunikat komunikat)
 {
     this.Logs.Add(new Komunikat()
     {
         TypKomunikatu = komunikat.TypKomunikatu, Tresc = komunikat.Tresc
     });
 }
예제 #5
0
파일: Serwer.cs 프로젝트: kuadam/lab_ts8
        static void Main(string[] args)
        {
            try
            {
                int       port      = 55123;
                UdpClient udpServer = new UdpClient(55123);

                string hostName = Dns.GetHostName(); // pobieranie nazwy
                Console.WriteLine("Nazwa serwera: " + hostName);

                // uzyskanie adresu IP
                string ip = Dns.GetHostByName(hostName).AddressList[0].ToString();
                Console.WriteLine("Adres IP:" + ip);

                UDPserwer serwer    = new UDPserwer();
                Komunikat komunikat = new Komunikat();

                serwer.Start(ref udpServer);
                while (true)
                {
                    serwer.Recive(ref udpServer);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }


            Console.ReadKey();
        }
예제 #6
0
        public LogViewModel(GlobalViewModel _globalViewModel)
        {
            globalViewModel = _globalViewModel;

            msg = new Komunikat();

            Logs = new ObservableCollection <Komunikat>();
        }
 public Proces(string name, int time, int group)
 {
     proces_name                = name;
     first_message              = null;
     running                    = false;
     blocked                    = false;
     stopped                    = false;
     proces_estimated_time      = time;
     proces_last_time           = 0;
     message_semaphore_common   = 0;
     message_semaphore_receiver = 0;
     semafor_info               = false;
     group_indeks               = group;
     instruction_done           = 0;
     czy_sprawdzony             = true;
 }
예제 #8
0
 public void fizzbuzz()
 {
     Komunikat = "";
     if (Liczba % 3 == 0)
     {
         Komunikat += "FIZZ";
     }
     if (Liczba % 5 == 0)
     {
         Komunikat += "BUZZ";
     }
     if (Komunikat.Equals(""))
     {
         Komunikat = "Liczba:" + Liczba + " nie spełnia kryteriów ";
     }
 }
예제 #9
0
        protected void BuyTicket_Click(object sender, EventArgs e)
        {
            if (LabelPrice.Text.ToString() == "")
            {
                string message = "alert('" + "Nie przeliczono ceny." + "');";
                ClientScript.RegisterStartupScript(this.GetType(), "Error_message", message, true);
                UpdateDivTickets();
                return;
            }

            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri("rabbitmq://*****:*****@hound.rmq.cloudamqp.com/luozycyv"),
                                    h => { });

                sbc.ReceiveEndpoint(host, "answerqueue", ep =>
                {
                    //   ep.Consumer<KomunikatConsumer>();
                });
            });

            bus.Start();

            string ticketRelease = "Ticket;" +
                                   RadioButtonList1.SelectedItem.ToString() + ";" + // type of ticket
                                   RadioButtonList2.SelectedItem.ToString() + ";" + // time of ticket
                                   LabelPrice.Text.ToString() + ";";

            List <ListItem> selectedItems = CheckBoxList1.Items.Cast <ListItem>()
                                            .Where(li => li.Selected)
                                            .ToList();

            foreach (var item in selectedItems)
            {
                if (item.Text.ToString() == "Strefa saun - 8zł")
                {
                    ticketRelease += item.Text.ToString();
                }
                else if (item.Text.ToString() == "Dostęp do zjeżdżalni - 4zł")
                {
                    ticketRelease += ", " + item.Text.ToString();
                }
                else if (item.Text.ToString() == "Strefa wypoczynkowa - 8zł")
                {
                    ticketRelease += ", " + item.Text.ToString();
                }
            }

            var ticketMessage = new Komunikat()
            {
                Tekst = ticketRelease,
                Dzien = DateTime.Now
            };

            bus.Publish <Komunikat>(ticketMessage);
            System.Threading.Thread.Sleep(3000);
            bus.Stop();

            UpdateDivTickets();
            LabelPrice.Text = "";
        }
예제 #10
0
        static void Main()
        {
            TcpListener server = null;

            try
            {
                int    L1 = 0, L2 = 0;
                bool   wygrana1 = false, wygrana2 = false;
                string hostName = Dns.GetHostName(); // pobieranie nazwy
                Console.WriteLine("Nazwa serwera: " + hostName);

                // uzyskanie adresu IP
                string ip = Dns.GetHostByName(hostName).AddressList[0].ToString();
                Console.WriteLine("Adres IP:" + ip);

                int port = 51997;
                server = new TcpListener(IPAddress.Any, port);

                server.Start();

                Byte[] bytes1 = new Byte[3];
                Byte[] bytes2 = new Byte[3];

                const String id1 = "001", id2 = "010";
                Komunikat    komunikat1 = new Komunikat(), komunikat2 = new Komunikat();

                {
                    Console.WriteLine("Oczekiwanie na polaczenie obu klientow... ");


                    TcpClient client = server.AcceptTcpClient();

                    NetworkStream stream1 = client.GetStream();


                    //nadanie identyfikatora klientowi 1
                    int i;
                    while ((i = stream1.Read(bytes1, 0, bytes1.Length)) != 0)
                    {
                        komunikat1.ustaw(bytes1);
                        if (komunikat1.GetOp() == "000001")
                        {
                            Console.WriteLine("Klient pierwszy polaczony! Nadano identyfikator " + Convert.ToInt32(id1, 2));
                            komunikat1.SetOp("000010");
                            komunikat1.SetId(id1);
                            komunikat1.GetBitArray().CopyTo(bytes1, 0);
                            stream1.Write(bytes1, 0, bytes1.Length);
                            break;
                        }
                    }


                    TcpClient client2 = server.AcceptTcpClient();

                    NetworkStream stream2 = client2.GetStream();

                    //nadanie identyfikatora klientowi 2
                    while ((i = stream2.Read(bytes2, 0, bytes2.Length)) != 0)
                    {
                        komunikat2.ustaw(bytes2);
                        if (komunikat2.GetOp() == "000001")
                        {
                            Console.WriteLine("Klient pierwszy polaczony! Nadano identyfikator " + Convert.ToInt32(id2, 2));
                            komunikat2.SetOp("000010");
                            komunikat2.SetId(id2);
                            komunikat2.GetBitArray().CopyTo(bytes2, 0);
                            stream2.Write(bytes2, 0, bytes2.Length);
                            break;
                        }
                    }

                    //odzczyt liczby przeslanej przez 1
                    while ((i = stream1.Read(bytes1, 0, bytes1.Length)) != 0)
                    {
                        komunikat1.ustaw(bytes1);
                        if (komunikat1.GetOp() == "000011")
                        {
                            L1 = Convert.ToInt32(komunikat1.GetLiczba(), 2);
                            Console.WriteLine(komunikat1.GetId() + " przesyla liczbe: " + Convert.ToString(L1), 2);
                            break;
                        }
                    }

                    //odzczyt liczby przeslanej przez 2
                    while ((i = stream2.Read(bytes2, 0, bytes2.Length)) != 0)
                    {
                        komunikat2.ustaw(bytes2);
                        if (komunikat2.GetOp() == "000011")
                        {
                            L2 = Convert.ToInt32(komunikat2.GetLiczba(), 2);
                            Console.WriteLine(komunikat2.GetId() + " przesyla liczbe: " + Convert.ToString(L2), 2);
                            break;
                        }
                    }


                    //Wyznaczanie przedzialu i wylosowanie liczby
                    int min, max;
                    min = L1 - L2;
                    if (min < 0)
                    {
                        min = 0;
                    }
                    max = L1 + L2;
                    if (max > 200)
                    {
                        max = 200;
                    }
                    Random random    = new Random();
                    int    zgadywana = random.Next(min, max);
                    Console.WriteLine("Wylosowano przedzial: <" + min + "," + max + ">\nZgadywna liczba to: " + zgadywana);

                    //przeslanie przedzialu klientowi 1
                    {
                        //min
                        komunikat1.Resetuj();
                        komunikat1.SetOp("000100");
                        //komunikat1.SetId(id1);
                        komunikat1.SetLiczba(Convert.ToString(min, 2).PadLeft(8, '0'));
                        komunikat1.GetBitArray().CopyTo(bytes1, 0);
                        stream1.Write(bytes1, 0, bytes1.Length);
                        //max
                        komunikat1.Resetuj();
                        komunikat1.SetOp("000101");
                        //komunikat1.SetId(id1);
                        komunikat1.SetLiczba(Convert.ToString(max, 2).PadLeft(8, '0'));
                        komunikat1.GetBitArray().CopyTo(bytes1, 0);
                        stream1.Write(bytes1, 0, bytes1.Length);
                    }

                    //przeslanie przedzialu 2

                    {
                        //min
                        komunikat2.Resetuj();
                        komunikat2.SetOp("000100");
                        //komunikat2.SetId(id2);
                        komunikat2.SetLiczba(Convert.ToString(min, 2).PadLeft(8, '0'));
                        komunikat2.GetBitArray().CopyTo(bytes2, 0);
                        stream2.Write(bytes2, 0, bytes2.Length);
                        //max
                        komunikat2.Resetuj();
                        komunikat2.SetOp("000101");
                        //komunikat2.SetId(id2);
                        komunikat2.SetLiczba(Convert.ToString(max, 2).PadLeft(8, '0'));
                        komunikat2.GetBitArray().CopyTo(bytes2, 0);
                        stream2.Write(bytes2, 0, bytes2.Length);
                    }

                    while (true)
                    {
                        while ((i = stream1.Read(bytes1, 0, bytes1.Length)) != 0)
                        {
                            komunikat1.ustaw(bytes1);
                            if (komunikat1.GetOp() == "000110")
                            {
                                //klient przesyla zgadywan liczbe
                                if (Convert.ToInt32(komunikat1.GetLiczba(), 2) == zgadywana)
                                {
                                    wygrana1 = true;
                                }
                                else if (Convert.ToInt32(komunikat1.GetLiczba(), 2) > zgadywana)
                                {
                                    komunikat1.Resetuj();
                                    komunikat1.SetOp("000111"); //odpowiedz serwera
                                    //komunikat1.SetId(id1);
                                    komunikat1.SetOdp("010");   //za duza
                                    komunikat1.GetBitArray().CopyTo(bytes1, 0);
                                    stream1.Write(bytes1, 0, bytes1.Length);
                                }
                                else if (Convert.ToInt32(komunikat1.GetLiczba(), 2) < zgadywana)
                                {
                                    komunikat1.Resetuj();
                                    komunikat1.SetOp("000111");
                                    //komunikat1.SetId(id1);
                                    komunikat1.SetOdp("011");//za mala
                                    komunikat1.GetBitArray().CopyTo(bytes1, 0);
                                    stream1.Write(bytes1, 0, bytes1.Length);
                                }
                                break;
                            }
                        }
                        while ((i = stream2.Read(bytes2, 0, bytes2.Length)) != 0)
                        {
                            komunikat2.ustaw(bytes2);
                            if (komunikat2.GetOp() == "000110")
                            {
                                //klient przesyla zgadywan liczbe

                                if (Convert.ToInt32(komunikat2.GetLiczba(), 2) == zgadywana)
                                {
                                    wygrana2 = true;
                                }
                                else if (Convert.ToInt32(komunikat2.GetLiczba(), 2) > zgadywana)
                                {
                                    komunikat2.Resetuj();
                                    komunikat2.SetOp("000111"); //odpowiedz serwera
                                    //komunikat2.SetId(id2);
                                    komunikat2.SetOdp("010");   //za duza
                                    komunikat2.GetBitArray().CopyTo(bytes2, 0);
                                    stream2.Write(bytes2, 0, bytes2.Length);
                                }
                                else if (Convert.ToInt32(komunikat2.GetLiczba(), 2) < zgadywana)
                                {
                                    komunikat2.Resetuj();
                                    komunikat2.SetOp("000111");
                                    //komunikat2.SetId(id2);
                                    komunikat2.SetOdp("011");//za mala
                                    komunikat2.GetBitArray().CopyTo(bytes2, 0);
                                    stream2.Write(bytes2, 0, bytes2.Length);
                                }
                                break;
                            }
                        }
                        if (wygrana1 && wygrana2)
                        {
                            komunikat1.Resetuj();
                            komunikat2.Resetuj();
                            komunikat1.SetOp("000111"); //odpowiedz serwera
                            //komunikat1.SetId(id1);
                            komunikat1.SetOdp("101");   //remis
                            komunikat1.GetBitArray().CopyTo(bytes1, 0);
                            stream1.Write(bytes1, 0, bytes1.Length);

                            komunikat2.SetOp("000111");
                            //komunikat2.SetId(id2);
                            komunikat2.SetOdp("101");//remis
                            komunikat2.GetBitArray().CopyTo(bytes2, 0);
                            stream2.Write(bytes2, 0, bytes2.Length);
                            break;
                        }
                        if (wygrana1)
                        {
                            komunikat1.Resetuj();
                            komunikat2.Resetuj();
                            komunikat1.SetOp("000111"); //odpowiedz serwera
                            //komunikat1.SetId(id1);
                            komunikat1.SetOdp("001");   //wygrana
                            komunikat1.GetBitArray().CopyTo(bytes1, 0);
                            stream1.Write(bytes1, 0, bytes1.Length);

                            komunikat2.SetOp("000111");
                            //komunikat2.SetId(id2);
                            komunikat2.SetOdp("100");//przegrana
                            komunikat2.GetBitArray().CopyTo(bytes2, 0);
                            stream2.Write(bytes2, 0, bytes2.Length);
                            break;
                        }
                        if (wygrana2)
                        {
                            komunikat1.Resetuj();
                            komunikat2.Resetuj();
                            komunikat1.SetOp("000111"); //odpowiedz serwera
                            //komunikat1.SetId(id1);
                            komunikat1.SetOdp("100");   //przegrana
                            komunikat1.GetBitArray().CopyTo(bytes1, 0);
                            stream1.Write(bytes1, 0, bytes1.Length);

                            komunikat2.SetOp("000111");
                            //komunikat2.SetId(id2);
                            komunikat2.SetOdp("001");//wygrana
                            komunikat2.GetBitArray().CopyTo(bytes2, 0);
                            stream2.Write(bytes2, 0, bytes2.Length);
                            break;
                        }
                    }
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
            finally
            {
                Console.WriteLine("\nNacisnij enter aby wyjsc...");
                Console.Read();
                server.Stop();
            }
        }
예제 #11
0
 private void Init_Komunikat()
 {
     _komunikat = GameObject.Find("Komunikat_Kursor").GetComponent <Komunikat>();
 }