Exemplo n.º 1
0
        protected override void ProcessRecord()
        {
            BoincSession previousSession = SessionState.PSVariable.GetValue("BoincSession", null) as BoincSession;

            if (previousSession != null)
            {
                previousSession.RpcClient.Dispose();
            }

            SessionState.PSVariable.Remove("BoincSession");

            BoincSession session = ConnectAndAuthorize();

            SessionState.PSVariable.Set("BoincSession", session);
        }
Exemplo n.º 2
0
        private BoincSession ConnectAndAuthorize()
        {
            if (Host == null)
            {
                WriteVerbose("No host was specified. Connecting to the local BOINC client.");

                Host = "localhost";

                if (Password == null)
                {
                    Password = ReadLocalGuiRpcPasswordFile();

                    if (Password == null)
                    {
                        WriteWarning(string.Format("Could not read local BOINC password from gui_rpc_auth.cfg. BOINC session will not be authenticated."));
                    }
                }
            }

            BoincSession session = new BoincSession(Host, Port);

            session.RpcClient.Connect(Host, Port);

            if (Password != null)
            {
                bool authorized = session.RpcClient.Authorize(Password);

                if (!authorized)
                {
                    throw new Exception("Error authenticating to BOINC client. Make sure the password is correct.");
                }

                session.Authenticated = true;
            }

            if (session.Authenticated)
            {
                WriteVerbose("Authenticated session established successfully.");
            }
            else
            {
                WriteVerbose("Unauthenticated session established successfully.");
            }

            return(session);
        }
Exemplo n.º 3
0
        protected override void ProcessRecord()
        {
            BoincSession previousSession = SessionState.PSVariable.GetValue("BoincSession", null) as BoincSession;

            if (previousSession != null)
            {
                previousSession.RpcClient.Dispose();

                WriteVerbose("Session closed successfully.");
            }
            else
            {
                WriteVerbose("There is no currently open session.");
            }

            SessionState.PSVariable.Remove("BoincSession");
        }