protected virtual void OnCompleteGameListingArrived(INetworkConnection con, Packet p)
        {
            PacketMatchRefresh packetMatchRefresh = p as PacketMatchRefresh;
            int totalGames = packetMatchRefresh.Parms.GetIntProperty("TotalGames").GetValueOrDefault(-1);

            FireCompleteMatchListingArrived(packetMatchRefresh.ReplyCode == ReplyType.OK, packetMatchRefresh.ReplyMessage, this, packetMatchRefresh.TheGames, totalGames);
        }
        private void OnGameListingRequest(INetworkConnection con, Packet gmsg)
        {
            PacketMatchRefresh note = (PacketMatchRefresh)CreatePacket((int)LobbyPacketType.MatchRefresh, 0, false, false);

            note.IsServerPacket = false;
            note.IsRefresh      = true;
            note.ReplyCode      = ReplyType.OK;
            note.Kinds.Add(MatchNotificationType.ListingRefresh);
            note.TargetPlayers.Add(null);
            gmsg.ReplyPacket = note;

            if (!ValidateHasCurrentCharacter())
            {
                note.ReplyMessage = "You must select a character before you can receive a content listing.";
                note.ReplyCode    = ReplyType.Failure;
                return;
            }

            PacketGenericMessage gp = gmsg as PacketGenericMessage;
            int  page              = gp.Parms.GetIntProperty("Page").GetValueOrDefault(0);
            int  numPerPage        = gp.Parms.GetIntProperty("NumPerPage").GetValueOrDefault(50);
            bool includeInProgress = gp.Parms.GetBoolProperty("IncludeInProgress").GetValueOrDefault(true);
            int  minPlayersAllowed = gp.Parms.GetIntProperty("MinPlayersAllowed").GetValueOrDefault(0);

            string    msg         = "";
            DataTable dt          = DB.Instance.Lobby_GetGameListing(page, numPerPage, "", includeInProgress, minPlayersAllowed, gp.Parms, out msg);
            bool      gotRowCount = false;

            if (dt != null)
            { // Transform data result into game object
                foreach (DataRow r in dt.Rows)
                {
                    if (!gotRowCount)
                    {
                        gotRowCount = true;
                        note.Parms.SetProperty("TotalGames", (int)r["TotalRows"]);
                    }
                    Game g = new Game();
                    g.GameID     = (Guid)r["GameID"];
                    g.Started    = (bool)r["InProgress"];
                    g.MaxPlayers = (int)r["MaxPlayersAllowed"];
                    g.Name       = (string)r["GameName"];
                    g.Properties.SetProperty("IsPrivate", (bool)r["IsPrivate"]);
                    g.Properties.SetProperty("PlayerCount", (int)r["CurrentPlayers"]);
                    // allow custom searches to add their additional data to the game object
                    OnGameSearchResultTransform(g, r);
                    note.TheGames.Add(g);
                }
            }
        }