Search code examples
androidnetwork-programmingnettynio

data exchange using sockets best option?


For mobile development i woud like to move something on the screen on a mobile device and on another mobile device you see the same object moving.

What would be my best option to use to exchange this data? I thought about firebase but the problem is you move the image alot of times so you easily get to the 50000 limit within an hour. also the fact that saving an position is abit odd to do in a database.

My second option would be using netty framework. I thought about using their socketstream option. My question about this is, my school stresses the use of an api between data exchange but is that also possible here? or is that more for webdevelopment?

In summery, What would be the best option to use for data exchange if you need to send alot of small request. If you sockets/nio framework is it normal to put an api between the client and server?


Solution

  • I thought about firebase but the problem is...

    You don’t need a database because you don’t want to save the object’s position. This data is not valuable to you (right?).

    You need to pass data from one device to the other to see the object moving. This can be done by establishing a network between these two devices. This can be done using sockets.

    If you sockets/nio framework is it normal to put an api between the client and server?

    If this API use sockets under the hood to simplify a client/server implementation for example then it’s not a good idea to use sockets. They’ve already being used by the API.

    On the other hand if the API does need socket implementation from your part to be used correctly, like the android Bluetooth API, then yes it’s normal.

    Your use case

    You can do this by connecting the two devices on the same network and transmit freely any data you like.

    If this network doesn’t need to be the Internet then you may want to transmit data over

    • Bluetooth
    • WiFi p2p
    • or your local WiFi using NSD

    For these and more see Android Connectivity.