Beispiel #1
0
        /// <summary>
        /// Sends the server's status to the Steam network.
        /// Results are returned in a <see cref="StatusReplyCallback"/> callback.
        /// </summary>
        /// <param name="details">A <see cref="SteamGameServer.StatusDetails"/> object containing the server's status.</param>
        public void SendStatus(StatusDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException(nameof(details));
            }

            if (details.Address != null && details.Address.AddressFamily != AddressFamily.InterNetwork)
            {
                throw new ArgumentException("Only IPv4 addresses are supported.");
            }

            var status = new ClientMsgProtobuf <CMsgGSServerType>(EMsg.GSServerType);

            status.Body.app_id_served   = details.AppID;
            status.Body.flags           = (uint)details.ServerFlags;
            status.Body.game_dir        = details.GameDirectory;
            status.Body.game_port       = details.Port;
            status.Body.game_query_port = details.QueryPort;
            status.Body.game_version    = details.Version;

            if (details.Address != null)
            {
                status.Body.deprecated_game_ip_address = NetHelpers.GetIPAddressAsUInt(details.Address);
            }

            this.Client.Send(status);
        }
Beispiel #2
0
        /// <summary>
        /// Requests a list of servers from the Steam game master server.
        /// Results are returned in a <see cref="QueryCallback"/>.
        /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result.
        /// </summary>
        /// <param name="details">The details for the request.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="QueryCallback"/>.</returns>
        public AsyncJob <QueryCallback> ServerQuery(QueryDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException(nameof(details));
            }

            var query = new ClientMsgProtobuf <CMsgClientGMSServerQuery>(EMsg.ClientGMSServerQuery);

            query.SourceJobID = Client.GetNextJobID();

            query.Body.app_id = details.AppID;

            if (details.GeoLocatedIP != null)
            {
                query.Body.geo_location_ip = NetHelpers.GetIPAddressAsUInt(details.GeoLocatedIP);
            }

            query.Body.filter_text = details.Filter;
            query.Body.region_code = ( uint )details.Region;

            query.Body.max_servers = details.MaxServers;

            this.Client.Send(query);

            return(new AsyncJob <QueryCallback>(this.Client, query.SourceJobID));
        }