Exemple #1
0
 /// <summary>
 /// Get array of Steam libraries
 /// </summary>
 /// <returns></returns>
 public static string[] GetGameLibraries()
 {
     lock (contextLock)
     {
         if (!context.SteamIsRunning)
         {
             return(null);
         }
         return(context.GetGameLibraries());
     }
 }
        public void HandleRequest(string uri, HttpRequest request, HttpResponse response, HttpContext httpcontext)
        {
            string[] uriParts = uri.Split('/');
            System.Collections.Specialized.NameValueCollection query = System.Web.HttpUtility.ParseQueryString(request.QueryString);

            if (uriParts.Length <= 1)
            {
                if (request.Method != HttpMethod.Get)
                {
                    throw new HttpMethodNotAllowedException();
                }

                //response.Headers[HttpHeaders.ContentType] = @"text/html; charset=UTF-8";
                //response.ResponseCode = HttpResponseCode.Ok;

                //byte[] raw = Encoding.UTF8.GetBytes(Resources.index);
                //response.Content.Write(raw, 0, raw.Length);

                throw new HttpNotFoundException();

                return;
            }

            switch (uriParts[0])
            {
            case "System":
                if (uriParts.Length > 1)
                {
                    switch (uriParts[1])
                    {
                    case "Exit":
                        Application.Exit();
                        return;
                    }
                }
                break;

            case "SteamContext":
                if (uriParts.Length > 1)
                {
                    switch (uriParts[1])
                    {
                    case "IsInstalled":
                        SendReponseData(request, response, context.IsInstalled(UInt64.Parse(query["GameID"])));
                        return;

                    case "GetGameLibraries":
                        SendReponseData(request, response, context.GetGameLibraries());
                        return;

                    case "InstallGame":
                    {
                        Steam4NET.EAppUpdateError?rawReturn = context.InstallGame(UInt64.Parse(query["GameID"]), int.Parse(query["GameLibraryIndex"]));
                        SendReponseData(request, response, rawReturn.HasValue ? (int?)rawReturn.Value : null);
                    }
                        return;

                    case "GetOwnedApps":
                        SendReponseData(request, response, context.GetOwnedApps());
                        return;

                    case "GetGoldSrcMods":
                        SendReponseData(request, response, context.GetGoldSrcMods());
                        return;

                    case "GetSourceMods":
                        SendReponseData(request, response, context.GetSourceMods());
                        return;

                    default:
                        throw new HttpNotFoundException();
                    }
                }
                else
                {
                    // readme?
                }
                break;
            }

            throw new HttpNotFoundException();
        }