Corona Cloud API - Multiplayer match

Hi everyone,

I’m new to this Corona cloud API platform, at them moment I’m trying to get the multiplayer match happening by making calls to the Web API interface. (not going through the Corona SDK but using a different platform to make http request to the cloud API)

There’s a bit of documentation here explainning how it works: http://docs.coronalabs.com/guide/cloud/multiplayer/index.html but most of the implementation info bits is about using the Corona SDK. So I have successfully got up to the creating and starting the match, the docs says that you would need to invite players to the match by calling the retrieving the user cloud id and, and explains that you can get that id by using the “friends.find(string)”. Since I’m not using the SDK but just making http calls to the Cloud, from what I can find in the API, there’s this function: http://docs.coronalabs.com/api_web/api/users/findUser.html that does that, I tried that a couple of times and got the 404 response everytime.

I have been reading through the documentation and the forum and found not much info regarding this. Was wondering if someone could give me some pointers.

Correct me if Im wrong, these are the assumptions that I made after reading through the docs:

       + Find the user by making this http request: http://docs.coronalabs.com/api_web/api/users/findUser.html , with one of the parameters being the keyword to search for (could be a last name, email…)

       + Then with the resulted json, you would get the user id to add to your friendslist or invite him to a match.

I was also wondering if push notifications need to be set up for each user before you can do all that?

Any help is appreciated, thanks.

J

Hi J,

I would look at the 'About Matches" http://docs.coronalabs.com/guide/cloud/multiplayer/index.html to get an idea of the overall flow.

Here is what you need to do.

You will need to create at least two accounts, Player A is the player who will create the match, and Player B is the opponent.

1. Player A creates a match:

https://api.coronalabs.com/matches.json?auth_token={{auth_token}}

Get the match ID = ‘_id’

Lets set it to match_id = _id

2. Player A will then search for Player B:

To search for a user, the call should look something like this:

https://api.coronalabs.com/users/search.json?auth_token={{auth_token}}&keyword=player_b@abc.com

Get Play B’s ID = ‘_id’

Lets set it to playerB_id = _id

3. You should then pass the ‘match_id’ and ‘playerB_id’ and use it to add that player:

https://api.coronalabs.com/matches/{{match_id}}/add_player.json?auth_token={{auth_token}}&user_id={{playerB_id}}

4. At this stage, if you have Push configured, a push message will be sent to Player B, otherwise Player B will need to do a getMatches (https://docs.coronalabs.com/api_web/api/multiplayer/getMatchDetails.html) to check if there are ‘pending matches’.

https://api.coronalabs.com/matches.json?auth_token={{auth_token}}

5. Player B will need to ‘accept’ the challenge

https://api.coronalabs.com/matches/{{match_id}}/accept_request.json?auth_token={{auth_token}}

6. Again if no Push is setup, Player A will need to do a getMatches to see if Player B has accepted

7. If Player B accepted, Player A can start the match:

https://api.coronalabs.com/matches/{{match_id}}/start.json?auth_token={{auth_token}}

8. Player A can now submit a move (you can actually start the match and submit a move before Player B accepts, so when they accept, they can start playing straight away)

Hope this helps.

Thanks

-Mohamed

Hi J,

I would look at the 'About Matches" http://docs.coronalabs.com/guide/cloud/multiplayer/index.html to get an idea of the overall flow.

Here is what you need to do.

You will need to create at least two accounts, Player A is the player who will create the match, and Player B is the opponent.

1. Player A creates a match:

https://api.coronalabs.com/matches.json?auth_token={{auth_token}}

Get the match ID = ‘_id’

Lets set it to match_id = _id

2. Player A will then search for Player B:

To search for a user, the call should look something like this:

https://api.coronalabs.com/users/search.json?auth_token={{auth_token}}&keyword=player_b@abc.com

Get Play B’s ID = ‘_id’

Lets set it to playerB_id = _id

3. You should then pass the ‘match_id’ and ‘playerB_id’ and use it to add that player:

https://api.coronalabs.com/matches/{{match_id}}/add_player.json?auth_token={{auth_token}}&user_id={{playerB_id}}

4. At this stage, if you have Push configured, a push message will be sent to Player B, otherwise Player B will need to do a getMatches (https://docs.coronalabs.com/api_web/api/multiplayer/getMatchDetails.html) to check if there are ‘pending matches’.

https://api.coronalabs.com/matches.json?auth_token={{auth_token}}

5. Player B will need to ‘accept’ the challenge

https://api.coronalabs.com/matches/{{match_id}}/accept_request.json?auth_token={{auth_token}}

6. Again if no Push is setup, Player A will need to do a getMatches to see if Player B has accepted

7. If Player B accepted, Player A can start the match:

https://api.coronalabs.com/matches/{{match_id}}/start.json?auth_token={{auth_token}}

8. Player A can now submit a move (you can actually start the match and submit a move before Player B accepts, so when they accept, they can start playing straight away)

Hope this helps.

Thanks

-Mohamed

Awesome thanks man! :slight_smile:

Awesome thanks man! :slight_smile: