示例#1
0
    public void OnLobby(string typeId, Action <Descriptor> callback)
    {
        Lobby      lb = lobbyMapping[typeId];
        Descriptor a1 = lb.Descriptor();

        if (a1.Category().Equals("game"))//request on game lobby
        {
            JSONObject jn = new JSONObject(JSONObject.Type.OBJECT);
            jn.AddField("command", "onLobby");
            jn.AddField("typeId", typeId);
            Application app = new Application(a1.Tag(), "onLobby", jn);
            Request(app, (resp) => {
                JSONObject jx = resp.GetField("gameList");
                for (int i = 0; i < jx.list.Count; i++)
                {
                    if (i < 3)
                    {
                        callback(new Descriptor(jx.list[i]));
                    }
                }
            });
        }
        else if (a1.Category().Equals("service"))//preload loop
        {
            lb.OnLobby(callback);
        }
    }