If you use getline() after cin >> anything, you must first flush the newline character from the buffer.
You can achieve this by using the cin.ignore()
It would be something like this:
string messageVar;
cout << "Type your message: ";
cin.ignore();
getline(cin, messageVar);
Because the >> operator leaves a newline n character in the input buffer, this happens.
When working with unformatted input, such as getline(), which reads until a newline character is discovered, this can be a problem.
Because of that n that was left hanging there in your previous operation, it will immediately stop reading.