I've got a conceptual question (which is probably better posted here than on StackOverflow?).I want to develop a client application that maintains a persistent connection to a server, and exchanges text data back and forth. An IRC client is a great example. So, these are givens:There is a fairly steady stream of incoming text that needs to be interpreted and dealt with in some way by the client.The client will send commands and it expects specifically formatted responses back from the server.There are probably quite a few approaches, but I'm looking for (obviously) the most efficient. Should I just manage all incoming text through the on data received event?(pseudo-code)on(data)  if data matches /###DAT action1/    handleAction1  else if data matches /###DAT action2/    handleAction2  else if data matches /###DAT PRIVMSG/    handlePrivateMessage  else if data matches /###DAT LOGIN_OK/    handleConfirmedLoginSo every possible bit of text that I'd want to deal with, is scanned here, whether it's a private message from someone, or a response to a login command I just sent.Is there a better way to deal with this? If it matters, I'm using JavaScript.
How to handle a client app that connects to a TCP server and sends/receives text data bidirectionally?
javascript;networking;client server;sockets