amazon-web-servicesazurecloud

How to transmit a song title via the cloud


I recently wrote a music player for Android for my personal use (mostly for fun but it as a few hyper-personalized features that I like). I would like to see the title of the currently playing song on my PC.

I have a vague notion that somehow I could have the Android app trigger some sort of event in a cloud and an app on the PC listen for that event. This feels like a push notification in reverse to me.

I am most strongly a C# developer and the PC app would be running on Linux. Because of this I am somewhat attracted to Azure, but AWS would be acceptable also. When I look at what Azure can do, I get overwhelmed by the sheer number of services it provides and I am uncertain what service I should try to use.

What cloud services would be appropriate for transmitting a string from a mobile device and getting notified on a Linux PC? Ideally something with a free tier.


Solution

  • The hardest part of it is the authorization.

    Assuming that you don't distribute either your mobile app or the PC app, and you can just bake your AWS credentials into them or their environment:

    1. Create an SQS queue (1M requests per months are free)
    2. Have your mobile app post a message to this SQS queue by calling IAmazonSQS.SendMessageAsync
    3. On your PC app, listen to the queue by calling IAmazonSQS.ReceiveMessageAsync in a loop.
    4. Once you're done with the message, delete it from the queue by calling IAmazonSQS.DeleteMessageAsync. Otherwise you'll keep receiving it over and over, until the you exceed the number of retry attempts and the messages falls off the queue.

    Note that receiving a message also counts as a request towards the quota, so you should use the long poll functionality.

    You'll need to provide long-term credentials for either application for it to work. Don't use your root account credentials for that. Spend an hour reading up on policies and permissions, create two separate sets of credentials for either app, and make sure to only give them permissions to post to the queue and read/delete from the queue, respectively. If these credentials leak, they won't be able to do a lot of harm.

    It is possible to do that without exposing your AWS credentials, but this will require connecting a lot of moving parts with the service called API Gateway which might be an overkill.

    Other cloud providers have similar services: Pub/Sub on Google Cloud and Queue Storage on Azure.