Saturday, 8 May 2021

Notify the player that another is challenging him

I am developing a simple multiplayer card game for Android.

I'm looking for the simplest (possibly free) solution to immediately alert the player that another is challenging him.

The actual flow:

  • Player1 presses a button to challenge player2
  • Player2 receives the notification in the game ONLY if he presses the "check new challenges" button

The desired flow:

  • Player1 presses a button to challenge player2
  • Player2 receives the notification almost immediately: in-game if the game is opened, through notification if the app was closed

My App is made with Java and LibGDX.

My server is a Linux web shared hosting with PHP 7.0.33, here I cannot install ratchet, composer or others, I haven't access to SSH.

Some details in phpinfo():

  • 'Configure Command' has '--enable-sockets=shared'
  • 'Registered Stream Socket Transports' has tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
  • 'curl - UNIX_SOCKETS' = true
  • 'sockets - Sockets Support' = `true'
  • 'default_socket_timeout' = true

I found these options on the web:

  • Firebase Cloud Messaging, firebase REST: Firebase solutions seem complex and time-consuming to set up and study, with a server (I only have shared web hosting) or push notifications requiring me to manually send the notification from the console
  • Schedule repeating alarms: it appears to have a 1 minute limit between two runs and up to two minutes to show the notification, as well as a background run time limit
  • PeriodicWorkRequest: (a type of WorkManager ) it has "a minimum interval of 15 minutes"
  • Server-Sent Events: I tried it. If both .html and .php files are on localhost it works fine, but instead if I put the .php file on my hosting I don't receive any messages (even if in the browser console in the network tabs every about 5 seconds a new request appeared).

Please tell me if I have written anything wrong and what you advise me to do based on your experience.

Thanks



from Notify the player that another is challenging him

No comments:

Post a Comment