Skip to content

Commit

Permalink
SID自動更新タイマーの停止とバージョンバンプ
Browse files Browse the repository at this point in the history
  • Loading branch information
onihusube committed Apr 25, 2024
1 parent 54d7444 commit eb71970
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion 2chAPIProxy/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:_2chAPIProxy" mc:Ignorable="d" x:Class="_2chAPIProxy.MainWindow"
Title="2chAPIProxy Ver:2024.04.17 nonAPI test" Height="480" Width="640"
Title="2chAPIProxy Ver:2024.04.26 nonAPI" Height="480" Width="640"
Icon="icon3.ico" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Background="White" d:DataContext="{d:DesignInstance {x:Type local:ViewModel}}">
<Window.InputBindings>
<KeyBinding Gesture="Ctrl+S" Command="{Binding SaveSetting}"/>
Expand Down
76 changes: 38 additions & 38 deletions APIMediator/APIAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public class APIAccess : IAPIMediator
ConcurrentDictionary<string, HoboData> m_HoboCache = new ConcurrentDictionary<string, HoboData>();

//SID自動更新用タイマー
Timer m_HoboCheck = null;
//Timer m_HoboCheck = null;

//タイマーの間隔
int m_ElapsedTime = 0;
//int m_ElapsedTime = 0;

//デフォルトのSID、これでdat取得等をすると更新が帰ってくる
static readonly string DefaultSID = "24435386Z78507D59284D46893Z55945T45741Z29183f65630d66139T82258c3442O53506n58942M48038D83651D14687r50234R6786f19427I86154p86883o54015c71781T19953D19830n36479K17338A62340746Z84798";
Expand Down Expand Up @@ -142,40 +142,40 @@ public APIAccess()
// ServicePointManagerの設定はプログラム?で共通。ここで設定すれば本体および他のdllでも設定されている

//SID自動更新タイマー開始
this.m_HoboCheck = new Timer((o) => {
//更新回数2回以下のデータを削除
var rmkey = from db in this.m_HoboCache.ToArray().AsParallel()
where db.Value.Count < 2
select db.Key;
foreach (var key in rmkey) this.m_HoboCache.TryRemove(key, out HoboData value);
//更新回数5回以下のデータをリセット
var rkey = from db in this.m_HoboCache.ToArray().AsParallel()
where db.Value.Count <= 5
select db.Key;
foreach (var key in rkey) this.m_HoboCache[key].Count = 0;
//更新回数6回以上のデータを5にセット
var skey = from db in this.m_HoboCache.ToArray().AsParallel()
where db.Value.Count > 5
select db.Key;
foreach (var key in skey) this.m_HoboCache[key].Count = 5;
this.m_ElapsedTime += 8;
if (this.m_ElapsedTime >= 24)
{
try
{
this.UpdateSID();
}
catch (Exception err)
{
System.Diagnostics.Debug.WriteLine(err.ToString());
CurrentError = $"SessionIDの更新に失敗しました。\n{err.ToString()}";
//ViewModel.OnModelNotice("SessionIDの更新に失敗しました。\n" + err.ToString());
}
this.m_ElapsedTime = 0;
}
this.m_HoboCheck.Change(3600000 * 8, -1);
}, null, 3600000 * 8, -1);
//this.m_HoboCheck = new Timer((o) => {
// //更新回数2回以下のデータを削除
// var rmkey = from db in this.m_HoboCache.ToArray().AsParallel()
// where db.Value.Count < 2
// select db.Key;
// foreach (var key in rmkey) this.m_HoboCache.TryRemove(key, out HoboData value);
// //更新回数5回以下のデータをリセット
// var rkey = from db in this.m_HoboCache.ToArray().AsParallel()
// where db.Value.Count <= 5
// select db.Key;
// foreach (var key in rkey) this.m_HoboCache[key].Count = 0;
// //更新回数6回以上のデータを5にセット
// var skey = from db in this.m_HoboCache.ToArray().AsParallel()
// where db.Value.Count > 5
// select db.Key;
// foreach (var key in skey) this.m_HoboCache[key].Count = 5;

// this.m_ElapsedTime += 8;
// if (this.m_ElapsedTime >= 24)
// {
// try
// {
// this.UpdateSID();
// }
// catch (Exception err)
// {
// System.Diagnostics.Debug.WriteLine(err.ToString());
// CurrentError = $"SessionIDの更新に失敗しました。\n{err.ToString()}";
// //ViewModel.OnModelNotice("SessionIDの更新に失敗しました。\n" + err.ToString());
// }
// this.m_ElapsedTime = 0;
// }
// this.m_HoboCheck.Change(3600000 * 8, -1);
//}, null, 3600000 * 8, -1);
}

/// <summary>
Expand Down Expand Up @@ -256,8 +256,8 @@ public void UpdateSID()
String hobo = KeyGen("/v1/" + key.Key + m_SID + this.AppKey);
this.m_HoboCache[key.Key].Hobo = Encoding.ASCII.GetBytes("sid=" + m_SID + "&hobo=" + hobo + "&appkey=" + this.AppKey);
}
this.m_HoboCheck.Change(3600000 * 8, -1);
this.m_ElapsedTime = 0;
//this.m_HoboCheck.Change(3600000 * 8, -1);
//this.m_ElapsedTime = 0;
}

/// <summary>
Expand Down

0 comments on commit eb71970

Please sign in to comment.