To mimic the human's typing, the message should be delayed naturally by the length of itself.
For example, message with 10 character should take 10/10 seconds to type, resulting a 1 second delay.
This should be implemented in Story class, specifically void Story::set_up_msg(Session session, long msg_time, std::string content)
.
But note that a challenge is that the next message from the same session should also be delayed correctly.
For example:
Message 1 was supposed to be sent at time 1. Because of the delay of 3 seconds, it will be sent at 1+3 = 4.
Message 2 was supposed to be sent at time 2. Because of the delay of 1 second, it will be sent at 2+1 = 3.
This will lead to a chaotic situation. To avoid such embarrassment, Story needs to record the cumulative delay as session.delay
.
So now the situation is:
Message 1 was supposed to be sent at time 1. Because of the delay of 3 seconds, it will be sent at 1+3 = 4. Record session.delay = 3
.
Message 2 was supposed to be sent at time 2. Because of the delay of 1 second, it will be sent at 2+session.delay
+1 = 6. Record session.delay += 1
.
Remember to reset session.delay
to 0
after sending a choice!