void StartSending(bool doRegistration = false)
 {
     if (IsSendingTimer)
     {
         return;
     }
     if (!Settings.IsAuthorized && !doRegistration)
     {
         return;
     }
     timerClient_ = new KanburaTimerClient(
         Constants.KanburaTimerUri,
         Settings.AdmiralID,
         doRegistration ? TimerSharingPassword : Settings.Password,
         Constants.KanburaTimerAgent);
     if (doRegistration)
     {
         timerClient_.Register(
             Settings.UserName);
         Settings.IsAuthorized = true;
     }
     sender_ = new Models.KanburaTimerSender(
         kanColleClient_,
         timerClient_,
         Settings.TimerSendDelay);
     sender_.SendFailed += sender__SendFailed;
     sender_.TimerSent  += sender__TimerSent;
     sender_.StartSending();
     if (doRegistration)
     {
         sender_.SendImmediately();
     }
 }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="kancolleData">艦これデータ</param>
        /// <param name="kanburaTimerUri">艦ぶらたいまーのサーバホスト名</param>
        /// <param name="userId">提督iD</param>
        /// <param name="password">パスワード</param>
        public KanburaTimerSender(
            KanColleClient kancolleClient,
            KanburaTimerClient client,
            int delay = 10000)
        {
            if (kancolleClient == null)
            {
                throw new ArgumentNullException("proxy");
            }
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (delay < 0)
            {
                throw new ArgumentOutOfRangeException("delay", "delay must be > 0");
            }
            proxy_  = kancolleClient;
            client_ = client;

            // 送信用タイマを作成
            timer_           = new Timer(delay);
            timer_.AutoReset = false;
            timer_.Elapsed  += SendTimerElapsed;
        }
 void StopSending()
 {
     if (!IsSendingTimer)
     {
         return;
     }
     timerClient_.Dispose();
     timerClient_ = null;
     sender_.Dispose();
     sender_ = null;
 }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="kancolleData">艦これデータ</param>
        /// <param name="kanburaTimerUri">艦ぶらたいまーのサーバホスト名</param>
        /// <param name="userId">提督iD</param>
        /// <param name="password">パスワード</param>
        public KanburaTimerSender(
            KanColleClient kancolleClient,
            KanburaTimerClient client,
            int delay = 10000)
        {
            if (kancolleClient == null) { throw new ArgumentNullException("proxy"); }
            if (client == null) { throw new ArgumentNullException("client"); }
            if (delay < 0) { throw new ArgumentOutOfRangeException("delay", "delay must be > 0"); }
            proxy_ = kancolleClient;
            client_ = client;

            // 送信用タイマを作成
            timer_ = new Timer(delay);
            timer_.AutoReset = false;
            timer_.Elapsed += SendTimerElapsed;
        }
 void StopSending()
 {
     if (!IsSendingTimer) { return; }
     timerClient_.Dispose();
     timerClient_ = null;
     sender_.Dispose();
     sender_ = null;
 }
 void StartSending(bool doRegistration = false)
 {
     if (IsSendingTimer) { return; }
     if (!Settings.IsAuthorized && !doRegistration) { return; }
     timerClient_ = new KanburaTimerClient(
         Constants.KanburaTimerUri,
         Settings.AdmiralID,
         doRegistration ? TimerSharingPassword : Settings.Password,
         Constants.KanburaTimerAgent);
     if (doRegistration) {
         timerClient_.Register(
             Settings.UserName);
         Settings.IsAuthorized = true;
     }
     sender_ = new Models.KanburaTimerSender(
         kanColleClient_,
         timerClient_,
         Settings.TimerSendDelay);
     sender_.SendFailed += sender__SendFailed;
     sender_.TimerSent += sender__TimerSent;
     sender_.StartSending();
     if (doRegistration) {
         sender_.SendImmediately();
     }
 }