I make an application on android, which interacts with the server through sockets. The server can receive various types of data and in response can send various types of data. How to organize interaction? Now I transfer the List<Objects> , in which the first element is the client id, the second is the operation identifier, and further I add the necessary data (always primitives). On the server side, cast to the right types. I cannot pass an object being serializable, because the package names are different. How to do?

  • Look in the direction of the REST-API of the data exchange protocols, I don’t think it’s worthwhile to invent something of your own, except to “play”. Usually, the data is transferred to http , https in json format - Igor Lavrynenko
  • Right, json. I forgot completely .... Answer, I will mark the decision. - Artem Altuhov
  • "Operation ID" may be the name of the method that processes this data. at the receiving end, using the reflection, the etod method is called and the data is transmitted. I have already been working on this in several projects - Vadim
  • Now you can use protocol websocket very well, it also has an encrypted version of wss. very economical, full duplex, can transmit both text and binary data. - Vadim

1 answer 1

Transfer data as text in json or xml format.