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:
cout << "Type your message: ";
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.