/// <summary>
        ///     Searches available lobbies based on the search criteria chosen in the <see cref="LobbySearchQuery" /> member
        ///     functions.
        ///     Lobbies that meet the criteria are then globally filtered, and can be accessed via iteration with
        ///     <see cref="LobbyCount" /> and <see cref="GetLobbyId" />.
        ///     The callback fires when the list of lobbies is stable and ready for iteration.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="callback"></param>
        public void Search(LobbySearchQuery query, SearchHandler callback)
        {
            GCHandle wrapped = GCHandle.Alloc(callback);

            Methods.Search(methodsPtr, query.MethodsPtr, GCHandle.ToIntPtr(wrapped), SearchCallbackImpl);
            query.MethodsPtr = IntPtr.Zero;
        }
        /// <summary>
        ///     Creates a search object to search available lobbies.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="ResultException"></exception>
        public LobbySearchQuery GetSearchQuery()
        {
            LobbySearchQuery ret = new LobbySearchQuery();
            Result           res = Methods.GetSearchQuery(methodsPtr, ref ret.MethodsPtr);

            if (res != Result.Ok)
            {
                throw new ResultException(res);
            }

            return(ret);
        }