Ejemplo n.º 1
0
        private void Authenticate()
        {
            if (!_passwordattempted)
            {
                _responseData = Chatstream.Read();
            }
            if (_responseData.IndexOf(AuthenticationProtocolValues.CommandPrompt, StringComparison.Ordinal) >= 0)
            {
                if (rb_register.Checked)
                {
                    Chatstream.Write(rb_register.Text);
                }
                if (rb_login.Checked)
                {
                    Chatstream.Write(rb_login.Text);
                }
                _responseData = Chatstream.Read();
            }

            if (_responseData.IndexOf(AuthenticationProtocolValues.UseridPrompt, StringComparison.Ordinal) >= 0)
            {
                rb_register.Enabled = false;
                rb_login.Enabled    = false;
                Chatstream.Write(tb_username.Text);
                _responseData = Chatstream.Read();
            }

            if (_responseData.IndexOf(AuthenticationProtocolValues.PasswordPrompt, StringComparison.Ordinal) >= 0)
            {
                tb_username.Enabled = false;
                Chatstream.Write(tb_userpassword.Text);
                _responseData = Chatstream.Read();
                if (rb_login.Checked)
                {
                    _passwordattempted = true;
                }
            }

            MessageBox.Show(FormatMessage(_responseData));

            if (_responseData.IndexOf(AuthenticationProtocolValues.QuitMsg, StringComparison.Ordinal) == 0)
            {
                DialogResult = DialogResult.Abort;
                Close();
            }

            if (_responseData.IndexOf(AuthenticationProtocolValues.AutenticatedMsg, StringComparison.Ordinal) == 0)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
            if (_responseData.IndexOf(AuthenticationProtocolValues.UserAlreadyLoggedIn, StringComparison.Ordinal) != 0)
            {
                return;
            }
            DialogResult = DialogResult.No;
            Close();
        }
Ejemplo n.º 2
0
        private void action_auto_get_media()
        {
            var s      = _responseData.Split(' ');
            var sender = "";

            if (s.Length >= 5)
            {
                sender = s[s.Length - 1];
            }
            action_message();
            var ext = shp1.Text.Substring(shp1.Text.Length - 3);

            _chatstream.Write(":get media:" + sender + ":" + ext);
        }
Ejemplo n.º 3
0
        public void Send_Click(object sender, RoutedEventArgs arg)
        {
            string message     = chatText.Text;
            string messageSend = User + ": " + message;

            if (message.Length <= 250)
            {
                ChatStream = chatClient.GetStream();        // connect to stream
                Byte[] sendBytes = new Byte[256];

                sendBytes = System.Text.Encoding.ASCII.GetBytes(messageSend);
                ChatStream.Write(sendBytes, 0, sendBytes.Length);       // send message

                chatText.Text = "";
                string chatMessage = "me: " + message;
                // create a listBox item
                chatBox.Items.Add(chatMessage);         // add chat to screen

                chatStream.Flush();
            }
            else
            {
                textError.Text = "You cannot exceed 250 characters";
            }
        }
Ejemplo n.º 4
0
 public void Send(Message message, Action messageSent, Action disconnect)
 {
     stream.Write(message.ToString(), null, disconnect);
 }