Example #1
0
        /// <summary>
        /// event listener for client textbox in chatlib or executor
        /// </summary>
        /// <param name="clientText"></param>
        private void Executor_ClientText(string clientText)
        {
            clientText = ClientInputTextBox.Text;
            stream     = client.GetStream();
            Byte[] data = System.Text.Encoding.ASCII.GetBytes(clientText);

            // Get a client stream for reading and writing.

            stream = client.GetStream();

            // Send the message to the connected TcpServer.
            stream.Write(data, 0, data.Length);

            if (ClientServerOuputTextBox.InvokeRequired)
            {
                MethodInvoker invoker = new MethodInvoker(delegate() {
                    //Executor.LoggingText(logFileName, " - Client: " + ClientInputTextBox.Text);
                    chatLog.MakeLog(" - Client: " + ClientInputTextBox.Text);
                    ClientServerOuputTextBox.AppendText("Client: " + ClientInputTextBox.Text + Executor.LineBreak());
                    ClientInputTextBox.Clear();
                });
                ClientServerOuputTextBox.Invoke(invoker);
            }
            else
            {
                //Executor.LoggingText(logFileName, " - Client: " + ClientInputTextBox.Text);
                chatLog.MakeLog(" - Client: " + ClientInputTextBox.Text);
                ClientServerOuputTextBox.AppendText("Client: " + ClientInputTextBox.Text + Executor.LineBreak());
                ClientInputTextBox.Clear();
            }
            //Responding to the end of the task.
            if (SendButton.Enabled == false)
            {
                if (SendButton.InvokeRequired)
                {
                    MethodInvoker invoker = new MethodInvoker(delegate() {
                        SendButton.Enabled = true;
                    });
                    SendButton.Invoke(invoker);
                }
                else
                {
                    SendButton.Enabled = true;
                }
            }
        }