Question

I'm writing a "Instant-Messaging software" using TCP server / client model using Java's socket API and I'm wondering what's the recommended way to call methods/functions of my clients from my server.

Currently I'm looking at sending a string over to my clients with a 3 characters in front of the string to allow my clients to determine what type of message it is.

For example:

  1. Server sends a string, "MSGhelloworld" to its clients
  2. Client splits the string into "MSG" and "helloworld"
  3. Client executes the 3 character command, "MSG" using a switch statement
  4. Then Client executes the corresponding method/function with "MSG" determining what method to execute and "helloworld" being the parameter for the method

I'm opened for any other recommended solutions and any UDP solutions as well, thank you.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top