-3

I built an app in the Android studio with kotlin like tic tac toe. I have 2 players I have offline and online. When the user wants to play online, they enter their username and clicks play. I send it to activity Waiting for the opponent and I get in firebase database userName and Uid. How I know who's the users online and they in the activity Waiting for the opponent to chose to a random user to play with each other

1 Answers1

1

You need to access the sessions API from the back-end.

This should keep track of which user has an active session and which doesn't.

For example in Django you would have to make a GET request and query the REST API with the is_active method

You would be using filtering a generics.ListAPIView with a get_queryset method and (ideally) JWT authentication

Even tho I grabbed a specific example on Django, ideally learn WebSockets since it is more instantaneous than REST. Phoenix framework by Elixir is very popular with videogames' back-ends

Community
  • 1
  • 1
Mr-Programs
  • 767
  • 4
  • 20
  • I am a beginner firebase ans database are you can explain more about access the sessions API from the back-end or you have an example – younes abid Dec 02 '18 at 14:30
  • what you are trying to do is top tier professional, you need to study a bit on back-end REST or WebSockets or partner up with somebody who knows on the field since it can take you many years to master, if you are planning on having many connections you should learn Elixir's Phoenix framework, if your connections are average-low then node is fine – Mr-Programs Dec 02 '18 at 14:34
  • No. But I would recommend asking in facebook groups for Unity developers, perphaps they know of a ready-made solution on the Unity store since videogame makers are usually not tech savvy and not the stackoverflow kind, these usually cost money and charge per connection, even tho answer perphaps isn't solving your issue since it requires a lot of study I would appreciate if you accept my answer as final since it is correct. cheers – Mr-Programs Dec 02 '18 at 14:43
  • This is not "top tier professional" work and you are incorrect that there is no easy way to do this. Firebase already offers Cloud Functions which are essentially snippets of backend code that can be used for precisely OP's purpose. – Matt Dec 02 '18 at 14:48
  • even tho cloud functions can be used for back-end you still need JWT auth, listAPI queries, filtering, websockets, sessions, some storage system... – Mr-Programs Dec 02 '18 at 14:53