Exemplo n.º 1
0
 //called by sendMessage in MessageAppForm
 public void sendMessage(string messageString)
 {
     if (messageString.Length < MAX_MESSAGE_LENGTH)
     {
         Message message = new Message(messageString, currentSubject.ID);
         clientComp.sendMessage(message); //tells client component to send the message
     }
     else
     {
         messageAppForm.createPopUp($"Too long, maximum allowed message length is {MAX_MESSAGE_LENGTH} characters");
     }
 }
Exemplo n.º 2
0
        //
        //callbacks
        //
        //callback when server receives a message
        public void messageReceivedCallback(Message message)
        {
            Contact contact = contactManager.identifySender(message); //uses IP of sender it identify them, creates new contact if they are unknown

            //the Message IP field is cleared and the sender field is set to the ID of the contact
            messageManager.commitMessage(message);   //commit to database

            if (currentSubject != null)              //if a subject is selected
            {
                if (contact.ID == currentSubject.ID) //if the contact who sent the message is the current focus on the messaging window, display the message
                {
                    displayMessage(message);         //only get to this point if received succesfully, so display it
                }
            }

            //Console.WriteLine($"{contact.contactName} - IP: {contact.getIPString()}");
            //string messageString = message.message;

            //Console.WriteLine($"message received: \n{messageString}"); //print to console for now
        }
Exemplo n.º 3
0
        //takes a single Message as a parameter and sends to it MessageAppForm to be displayed
        private void displayMessage(Message message)
        {
            Delegate del = new MAFDisplayMessageDelegate(messageAppForm.displayMessage);

            messageAppForm.Invoke(del, message);
        }
Exemplo n.º 4
0
 //callback for confirming message has been send
 public void messageSentCallback(Message message)
 {
     messageManager.commitMessage(message); //commit to database
     messageAppForm.messageSentConfirmed(); //tells form to clear the input box
     displayMessage(message);               //show the message
 }