public override void Activate() { actionQueue = new Queue<PiVoteAction>(); certificateStorage = new CertificateStorage(); if (!certificateStorage.TryLoadRoot("./root.pi-cert")) { throw new Exception("Cannot find root certificate file."); } client = new VotingClient(certificateStorage); var serverIpAddress = Dns.GetHostEntry(PiVoteServerAddress).AddressList.First(); var serverIpEndPoint = new IPEndPoint(serverIpAddress, PiVoteServerPort); client.Connect(serverIpEndPoint); BotMethods.AddCommand(new Commandlet(CommandListVotings, CommandListVotingsDescription, ListVotingsHandler, this)); BotMethods.AddCommand(new Commandlet(CommandTally, CommandTallyDescription, TallyHandler, this)); BotMethods.AddCommand(new Commandlet(CommandStatus, CommandStatusDescription, StatusHandler, this)); base.Activate(); }
/// <summary> /// Execute the operation. /// </summary> /// <param name="client">Voter client to execute against.</param> public override void Execute(VotingClient client) { try { Text = LibraryResources.ClientConnect; Progress = 0d; SubText = string.Empty; SubProgress = 0d; if (!client.client.Connected) { if (proxyEndPoint == null) { client.Connect(this.serverEndPoint); } else { client.Connect(this.serverEndPoint, this.proxyEndPoint); } } Progress = 1d; this.callBack(null); } catch (Exception exception) { this.callBack(exception); } }