Exemplo n.º 1
0
 private void sendMessage_Click(object sender, EventArgs e)
 {
     if (receiver.contact_id != 0)
     {
         if (messageBox.Text.Length > 0)
         {
             messageBox.Text = messageBox.Text.Replace("\n", "");
             if (SocialRequests.postMessage(receiver.contact_id,
                                            Functions.RSA.Encrypt(messageBox.Text, receiver.public_key)).message == "success")
             {
                 addMessage(messageBox.Text, true);
                 messageBox.Text = "";
             }
         }
         else
         {
             //no messege to send
             MessageBox.Show("Please write a message before sending!");
         }
     }
     else
     {
         //no contact selected
         MessageBox.Show("Please select a contact to chat with!");
     }
 }
Exemplo n.º 2
0
        private static void openChat(object sender, EventArgs e)
        {
            Messages chat = SocialRequests.getMessages(receiver.contact_id, lastSeen);

            chat.messages.Reverse();
            if (lastSeen == "false")
            {
                lastSeen = "true";
            }

            foreach (SnS.Classes.UserController.Objects.Message message in chat.messages)
            {
                message.message = Functions.RSA.Decrypt(message.message);
                if (message.sent == 0)
                {
                    self.addMessage(message.message, false);
                }
                else
                {
                    self.addMessage(message.message, true);
                }
            }
        }