Search code examples
javainputchatdelayirc

Which chat pattern is better: print the message upon input, or after the server receives it?


Basically, I'm developing a chat client, like an IRC. Then, I got into the dilemma: when the client sends the message, should this message be printed instantly on his client chat, or should the server re-send the message for him, and then it will be printed?

For example, Facebook, MSN and Skype, uses the first approach, but the chat I'm building is going to be a really "uber-nerd-only", so I don't know which pattern should I use.

It is important to note, that the messages can take a while to be sent and received by either sides. For example, a simple "Hello" will probably turn into a 100-length char array (don't ask me why).

According to this situation, which pattern is going to be better, and why?


Solution

  • After user clicked "send" button message should appear in his chat with icon "in progress", as soon as server confirmed that message is received - icon should be removed or changed to "received", in case of timeout - change icon to "error" with possibility to retry sending

    Doing this way you satisfy both requirements:

    1. Interface responsiveness (you see result immediately)
    2. Interface informativity (you know actual status and what is going on)