Demo Webscript.io Code has issues

Hey guys,

Just wanted to update you that the webscript.io demo code at :

https://github.com/exitgames/photon.web ... .webscript

breaks the client in the Memory Game Demo. This happened when I started using my own webhooks using this code as the starting point.

A temporary fix I had to put in (MemoryGameClient.cs - line 234) was :
//si.MyPlayerId = (int)roomValues["ActorNr"];
//si.AvailableProperties = roomValues["Properties"] as Dictionary<string, object>;

si.MyPlayerId = int.Parse((string)(pair.Value));
si.AvailableProperties = null;

This removes the crash but causes the saved games to not be able to be entered anymore.

If I revert to using the Turnbased Demo Webhooks it works again, so maybe the lua webscript.io scripts were not updated.

Comments

  • yes - we haven't updated the scripts jet.

    I'll update the readme in the meantime - sorry about that.
  • Hi again,

    the webscript lua scripts are now up to date:
    https://github.com/exitgames/photon.web ... .webscript

    They don't have the PushWoosh push notifications integration, but it does show how to access the information we
    use in .net webhooks to trigger the Pushnotification. Check out the script GameProperties.

    -Philip
  • Awesome!

    Thanks for the quick reply. Will check it out.
  • Hi Philip,

    Looks good. There is only one change I had to make to the lua code :

    In GetGameList.lua (line 30),

    Properties = json.parse(state).LobbyProperties

    instead of json.parse(state).CustomProperties.
  • Hi ZenCoder,

    I just saw your message - it should actually be json.parse(state).CustomProperties.

    Probably missed the case where its not set - haven't tested jet.

    Below is a sample state of a room - where the client sets the following properties to create the room

    [code2=csharp]myRoomOptions.MaxPlayers = 4;
    myRoomOptions.IsOpen = true;
    myRoomOptions.IsVisible = true;
    myRoomOptions.CustomRoomProperties = new Hashtable
    {
    { "prop1Key", "prop1Val" },
    { "prop2Key", "prop2Val" },
    { "lobby3Key", "lobby3Val" },
    { "lobby4Key", "lobby4Val" },
    { "map_name", "mymap" }
    };
    myRoomOptions.CustomRoomPropertiesForLobby = new string[] { "lobby3Key", "lobby4Key" };

    this.OpCreateRoom(roomname, myRoomOptions, this.CurrentLobby);[/code2]

    And where ONLY the properties marked through CustomRoomPropertiesForLobby are beeing propagated
    a.) to the lobby
    b.) to the saved gameslist

    Hope that makes sense ...

    Note: don't rely on the DEBUG_BINARY parts those will be removed.

    [code2=javascript]{
    "LobbyProperties": [
    "lobby3Key",
    "lobby4Key"
    ],
    "LobbyId": "MyLobby",
    "MaxPlayers": 4,
    "Slice": 0,
    "CustomProperties": {
    "lobby4Key": "test1b",
    "lobby3Key": "test1a"
    },
    "IsOpen": true,
    "Binary": {
    "18": "RAAAAApi/m8BYv1vAXMACHByb3AxS2V5cwAIcHJvcDFWYWxi+nkAAnMACWxvYmJ5M0tleQAJbG9iYnk0S2V5Yv9iBHMACHByb3AyS2V5cwAIcHJvcDJWYWxzAAlsb2JieTRLZXlzAAZ0ZXN0MWJzAAlsb2JieTNLZXlzAAZ0ZXN0MWFzAAhtYXBfbmFtZXMABW15bWFwcwAEdHVybmkAAAAB"
    },
    "LobbyType": 2,
    "SuppressRoomEvents": false,
    "EmptyRoomTTL": 0,
    "CheckUserOnJoin": true,
    "PlayerTTL": 2147483647,
    "DEBUG_PROPERTIES_18": {
    "250": [
    "lobby3Key",
    "lobby4Key"
    ],
    "253": true,
    "254": true,
    "255": 4,
    "lobby3Key": "test1a",
    "prop2Key": "prop2Val",
    "lobby4Key": "test1b",
    "prop1Key": "prop1Val",
    "turn": 1,
    "map_name": "mymap"
    },
    "ActorList": [
    {
    "Username": "MyPlayer0",
    "Binary": "RGIAAAEBRAAAAAJzAAlwbGF5ZXJfaWRzAAUxMjM0NWL/cwAJTXlQbGF5ZXIw",
    "DEBUG_BINARY": {
    "1": {
    "255": "MyPlayer0",
    "player_id": "12345"
    }
    },
    "UserId": "MyUserId0",
    "ActorNr": 1
    }
    ],
    "IsVisible": true,
    "ActorCounter": 1,
    "DeleteCacheOnLeave": true
    }[/code2]