Expand my Community achievements bar.

SOLVED

Private Room for Game Play

Avatar

Level 3

I am working on a multiplayer chess game. I have got it working using a SharedCollection object which stores each move. I also have a custom user field which stores the piece color. At the moment I have a login which logs the user into a Collection Node which has been previously setup (after logging in as a HOST). Many people can log into the game but the first two visitors become the game players. This has worked really well for the development stage of my project, however now I want to take it to the next level...

I have been investigating the MultipleGoups sample app and I think it is a great starting point, however I would like to be able to have the following scenario:

1 -  A main chat area where users can challenge other players to a game.


2 - Once the challenge is made (click on the opponent), a private room is created and then the game starts between the two people.

My biggest hurdle is understanding how I can set up a system where this would occur without the intervention of a HOST to create a new Rooms and CollectionNodes for the game. (Perhaps the challenger can become a HOST?)

Any help would be greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi there Justoliver,

This feels to me like

1. a lobby room where people challenge each other (or perhaps several lobbies)

2. when 2 people accept a challenge, they ping your web server with some sort of RPC call.

3. Your web server then spawns a new room for the pair, using the server integration APIs, and returns the new roomURL to your 2 clients. The room would be created from a template which contains the collection nodes you need (so no need for a host to set them up).

4. The 2 people head on over to the new room and play privately.

So in this case, your web server acts as the host needed to set up the appropriate rooms. Check out the AFCS Developer Guide - chapter 6 has details on building this sort of thing.

nigel

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

Hi there Justoliver,

This feels to me like

1. a lobby room where people challenge each other (or perhaps several lobbies)

2. when 2 people accept a challenge, they ping your web server with some sort of RPC call.

3. Your web server then spawns a new room for the pair, using the server integration APIs, and returns the new roomURL to your 2 clients. The room would be created from a template which contains the collection nodes you need (so no need for a host to set them up).

4. The 2 people head on over to the new room and play privately.

So in this case, your web server acts as the host needed to set up the appropriate rooms. Check out the AFCS Developer Guide - chapter 6 has details on building this sort of thing.

nigel

Avatar

Employee

What Nigel is suggesting is a very cool approach. But just wondering why its a bad idea: to just create a new collection node and restrict communication to the new node for the new players only.

Thanks

Arun

Avatar

Level 3

Hi Arun

Your suggestion is helpful, however I can't seem to find a function (in the php External Authentication class) which will allow me to create a CollectionNode. The class only provides createRoom. Perhaps I could create my own function createNode with the following line change?

$data = "mode=xml&node={$node}&room={$room}&template={$template}&{$this->authToken}";

If anyone has a suggestion that would be great.

Avatar

Employee

Defintively not

The create room REST API only creates the room, you can pass a node parameter, but it's not going to do anything

We are planning more REST API that will let you query and manipulate your model, but they are not available yet, so for now I think Nigel's suggestion is the best (and as you discovered, Arun suggestion requires you to be the owner to create the new nodes)

Avatar

Level 3

Thanks Raff - thats what I thought

Avatar

Level 3

Hi Nigel

I have successfully created a lobby in my application. When a user clicks on another user, an HTTP POST is triggered calling a php script to create the room.

So create room works fine if the room dosen't exist but the afcs.php class throws a php warning if the room does exist.

The warning corrupts the value of the message that the swf receives.

The warning is:

Warning:  fopen(https://na2.connectnow.acrobat.com:443///{accountname}) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden  in afcs.php on line 560

A connection-failed exception is also returned.

Here is a code snippet:

    try {
        $am->createRoom( $s_room, $s_template );
    } catch (AFCSError $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
        $b_ready = false;
    }

Do you have a newer version of afcs.php?

I also tried using getRoomInfo and this seems to return some kind of pseudo-SOAP message which has a status tag containing a reponse. How can I interpret the room data being returned?

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----