How to invite a specific player to play a game

0 votes
My game is a 2-player realtime quiz game running on iOS and written using Corona SDK.  

You can add your friends to the game by linking to your facebook account, which will connect you with any of your facebook friends that have ever launched the app.

I need to write the functionality for inviting one of these friends to play a game,  They may or may not be logged in to the game at the time.  

I was thinking of using the following process, and just want to verify my approach before I burn too much time implementing:

1. The first time a player launches the game, we have to give them a unique identifier for the game.  We could use their facebook id, but I would prefer to create my own unique identifier for each player (in case I want to support logging in via other networks)

2. When you add friends to your profile, their unique identifier will be stored along with your profile.

3. Each player joins the lobby when they connect to the game

4.When joining the game, determine which of your friends are online by checking to see if they are in the lobby using the unique identifier for them that you have stored in step 2 (side question: what is an efficient way of seeing which of your friends are in the lobby if you have lots of friends, and there are potentially lots of users in the lobby?)

 5. If you want to invite a friend who is already in the lobby, send a message through the App Warp API with an invitation to play a game.

6. If you want to invite a friend that is not already in the lobby, send them an invitiation using Push Notification.

If they tap on your notification message, it will launch the app, and if you are still in the lobby (i.e. havent quit the app or started playing someone else), the app will notify you that they have accepted your invitation.

7. Once the app has determined that you both want to play against each other, the inviter's app instance will create a new room, and both players will join the room.  

8. Once both players join the room its game on!  If both players haven't joined the room within a specific time-frame, the game will be discarded and the room will be removed.  (Side question: what if both players quit the app, can you be left with orphaned rooms?  Whats the best-practice for handling this)

 

All of the above seems like quite a lot of work to implement manually so I was wondering whether the App Warp platform assists with any of this, or am I correct in my assumption that I will need to code a lot of it as per the process above.  I'm open to suggestions as to how to implement, my primary goal is to not require any additional server resources (other than AppWarp obviously) if I can help it
asked Mar 9, 2014 in AppWarp by matthew.oleary (10 points)

1 Answer

0 votes

Hi Matthew,

There are lots of parts to your question - its best you create separate questions for the individual problems. I'll do my best to point you in the right direction :-)

Non-AppWarp queries

For storing user data - you have the option of user App42 User management APIs. For storing User Ids and their friends - you can take a look at the Storage Service of App42. 

http://api.shephertz.com/app42-dev/corona-backend-apis.php

There is also a corona sample that you can take a look at.

We are also working on integrating push notification service in our App42 corona APIs. We will update once its ready.

AppWarp specific queries..

For inviting online users - you can use the privateChat API of appwarp. Once both are ready to play - the sender can create the room and over private chat send the room id of the newly created room to the other person. Your approach regarding this looks fine to me.

There is a getLiveLobbyInfo API that will return to you all the users who are in the lobby. You can then compare this with your own friend list.

Orphaned rooms (empty dynamic rooms) are automatically deleted on the server after one hour.

 

answered Mar 9, 2014 by dhruvc (1,099 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...