Exemple #1
0
        private void SendString(string text)
        {
            byte[] buffer = Rc6.GetBytes(text);

            byte[] outputText = Rc6.Enc(buffer);

            ClientSocket.Send(outputText, 0, outputText.Length, SocketFlags.None);
        }
Exemple #2
0
        //private static void Exit()
        //{
        //    SendString("exit"); // Tell the server we are exiting
        //    ClientSocket.Shutdown(SocketShutdown.Both);
        //    ClientSocket.Close();
        //    Environment.Exit(0);
        //}

        private void UpdateTextBox(object obj)
        {
            // do we need to switch threads?

            if (InvokeRequired)

            {
                // we then create the delegate again

                // if you've made it global then you won't need to do this

                ObjectDelegate method = new ObjectDelegate(UpdateTextBox);



                // we then simply invoke it and return

                Invoke(method, obj);

                return;
            }

            // ok so now we're here, this means we're able to update the control

            // so we unbox the object into a string

            string text = (string)obj;

            // and update

            if (String.Equals(odabrano, "Bob"))
            {
                txtSourceText.Text = text;

                string dekr = Rc6.Dekriptuj(text);

                txtDestinationText.Text += dekr + "\r\n";
            }
            else
            {
                txtDestinationText.Text += text + "\r\n";
            }
        }
Exemple #3
0
        private void ReceiveResponse()
        {
            var buffer   = new byte[2048];
            int received = ClientSocket.Receive(buffer, SocketFlags.None);

            if (received == 0)
            {
                return;
            }

            var data = new byte[received];

            Array.Copy(buffer, data, received);


            if (String.Equals(odabrano, "Bob"))
            {
                String text1 = Rc6.GetString(data);
                txtSourceText.Text = text1;

                byte[] outputText = Rc6.Dec(data);
                string text       = Rc6.GetString(outputText);

                string dekr     = Rc6.Dekriptuj(text);
                String zaPrikaz = "Primljeno: " + text;
                txtDestinationText.Text += zaPrikaz;
                txtDestinationText.Text += "\r\n";
            }
            else
            {
                String text1    = Rc6.GetString(data);
                String zaPrikaz = "Poslato: " + text1;
                txtDestinationText.Text += zaPrikaz;
                txtDestinationText.Text += "\r\n";
            }
            // listMessages.Items.Add("Received: " + text);
        }