コード例 #1
0
ファイル: Form1.cs プロジェクト: piotrmalecki/TSST
        void Run()
        {
            send(Protocol.LOGIN + " " + name, output);
            //ChangeText("WYSLALEM");
            while (true)
            {
                String command = receive();
                // ChangeText("Serwer: " + command);
                string[] tab = command.Split(' ');
                command = tab[0];

                if (command.Equals(Protocol.CONFIRMATION))
                {
                    ChangeText("Przyszło CONFIRMATION");
                }

                else if (command.Equals(Protocol.CALL_IND))
                {
                    String odKogo = tab[1];
                    ChangeText("Przyszło CALL_INDIC. " + odKogo);
                    send(Protocol.CALL_ACCEPT, output);
                    ChangeText("Wysylam CallAccept");
                }

                else if (command.Equals(Protocol.CALL_FAIL))
                {
                    ChangeText("Przyszło CALL FAILED ");
                }

                else if (command.Equals(Protocol.CALL_ACCEPT))
                {
                    f1        = tab[1];
                    f2        = tab[2];
                    modulacja = "1";
                    ChangeText("Przyszło CALL ACCEPT");
                    ChangeText(f1 + " " + f2 + " " + modulacja);
                    sendMsg = true;
                }



                else if (command.Equals(Protocol.PARAMETERS))
                {
                    ChangeText("Przyszło PARAMETERS");
                    eon = new sygnaleon(Protocol.PARAMETERS + " " + tab[1] + " " + tab[2] + " " + tab[3]);

                    f1        = tab[1];
                    f2        = tab[2];
                    modulacja = tab[3];
                }
                else if (command.Equals(Protocol.NULLCOMMAND))
                {
                    break;
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: piotrmalecki/TSST
        //listBox1.Text= Convert.ToString(ID_client2);
        //public Socket m_socListener;
        //id naszego aktualnego rozmowcy

        public Form1(string ID)
        {
            name = ID;
            InitializeComponent();
            switch (name)
            {
            case "Franek":
                ID_client2 = 1;
                break;

            case "Henio":
                ID_client2 = 2;
                break;

            case "Zenek":
                ID_client2 = 3;
                break;
            }
            //Int32[] conf=new Int32[1];
            //String path = @"D:\Dane.txt";
            //conf = TextReader.ReadTextFromFile(@"dane.txt");

            listBox1.Items.Add(name);

            //ID_client = 1; //conf[0];
            s = new sygnaleon();
            IPAddress ipadres  = IPAddress.Parse("127.0.0.1");
            string    host     = "127.0.0.1";
            int       port2    = 10100;
            IPAddress ipadres1 = IPAddress.Parse("127.0.0.1");
            string    host1    = "127.0.0.1";
            int       port;

            if (viaManagement)
            {
                port = 30001;
            }
            else
            {
                port = 40001;
            }
            try
            {
                tcpClient = new TcpClient(host1, port);
            }
            catch (SocketException e1)
            {
                ChangeText("Nie udało się nawiązać połączenia z aplika");
                MessageBox.Show(e1.ToString());
            }
            try
            {
                NetworkStream clientSockStream = tcpClient.GetStream();
                input  = new StreamReader(clientSockStream);
                output = new StreamWriter(clientSockStream);
            }
            catch (IOException e2)
            {
                ChangeText("Błąd strumienia wejścia/wyjścia");
            }

            Thread clientThread = new Thread(new ThreadStart(this.Run));

            clientThread.Start();



            try
            {
                tcpClientCloud = new TcpClient(host, port2);
            }

            catch (SocketException e)
            {
                ChangeText("Nie udało się nawiązać połączenia z aplika");
                MessageBox.Show(e.ToString());
            }
            try
            {
                clientSockStreamCloud = tcpClientCloud.GetStream();
                inputCloud            = new StreamReader(clientSockStreamCloud);
                outputCloud           = new StreamWriter(clientSockStreamCloud);
            }
            catch (IOException e)
            {
                ChangeText("Błąd strumienia wejścia/wyjścia");
            }

            Thread appThread_cable = new Thread(new ThreadStart(this.Run_Cable));

            appThread_cable.Start();

            send(Protocol.LOGIN + " " + ID_client2 + " c", outputCloud);
        }