private void SendInbox(ServerForm parent, ServerInboxWindow main, TcpClient clientSocket)
        {
            string data = main.serverInboxInput.Text;

            Storage.RichTextBoxAppend(main.serverInbox, $"You: {data}");
            parent.serverInbox = $"You: {data}";

            NetworkStream stream = new NetworkStream(clientSocket.Client, false);

            byte[] buffer = Encoding.UTF8.GetBytes($"i{data}");
            stream.Write(buffer, 0, buffer.Length);
            stream.Close();

            Storage.TextBoxClear(main.serverInboxInput);
        }
Пример #2
0
        // Func
        private void __destructor()
        {
            if (terminal != null)
            {
                terminal.Stop();
            }

            if (clientSocket != null)
            {
                try
                {
                    NetworkStream stream = new NetworkStream(clientSocket.Client, false);
                    byte[]        buffer = Encoding.UTF8.GetBytes(@"!@#$%^&*()_+EXIT!@#$%^&*()_+");
                    stream.Write(buffer, 0, buffer.Length);
                    stream.Close();
                }
                catch { }
                clientSocket = null;
            }

            if (listenThread != null)
            {
                listenThread.Abort();
                listenThread = null;
            }
            if (serverShellWindow != null)
            {
                serverShellWindow.Invoke(new MethodInvoker(delegate()
                {
                    serverShellWindow.Close();
                    serverShellWindow = null;
                }));
            }
            if (serverInboxWindow != null)
            {
                serverInboxWindow.Invoke(new MethodInvoker(delegate()
                {
                    serverInboxWindow.Close();
                    serverInboxWindow = null;
                }));
            }
            if (serverSocket != null)
            {
                serverSocket.Stop();
                serverSocket = null;
            }
        }