简体   繁体   中英

Better way for sending data through socket

I have android applicatoin which is sending location to server every 4 seconds, and than server send all locations from clients to every client. For server code I'm using java. I create object Position which have four variabls (username, time, latitude, longitude). I send this object to server on every update and than on server I save this in database.

Every 5 seconds I send all locations from server to every client. For every user I create object Position and all objects than send in ArrayList through socket to clients. My question is, if this is best approach, or whould be faster if data on server would be written into json or xml and than would be send to client.

  1. JSON is better than XML because it takes less size so transfer the rate is faster.
  2. Use WebSockets for periodic duplex connections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM