Вопрос

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.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top