Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3206e79

Browse files
committed
Merge branch 'release'
2 parents 665dd32 + a84baba commit 3206e79

File tree

10 files changed

+96
-74
lines changed

10 files changed

+96
-74
lines changed

‎MultiCommentViewer/Properties/AssemblyInfo.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
[assembly: InternalsVisibleTo("MultiCommentViewerTests")]
55

6-
[assembly: AssemblyVersion("0.6.29")]
6+
[assembly: AssemblyVersion("0.6.30")]

‎ShowRoomSitePlugin/ShowRoomCommentProvider.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void ProcessT1(T1 t1, bool isInitialComment)
120120
var userId = message.UserId;
121121
var isFirstComment = _first.IsFirstComment(userId);
122122
var user = GetUser(userId);
123-
user.Name = Common.MessagePartFactory.CreateMessageItems(message.Text);
123+
user.Name = Common.MessagePartFactory.CreateMessageItems(message.UserName);
124124
var metadata = CreateMessageMetadata(message, user, isFirstComment, isInitialComment);
125125
var methods = new MessageMethods();
126126
RaiseMessageReceived(new MessageContext(message, metadata, methods));

‎SitePluginCommon/AutoReconnection/ConnectionManager.cs‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,37 @@
66

77
namespace SitePluginCommon.AutoReconnection
88
{
9+
public class ReconnectionCounter
10+
{
11+
Queue<DateTime> _list = new Queue<DateTime>();
12+
/// <summary>
13+
///
14+
/// </summary>
15+
/// <returns>一定時間内のAdd回数が一定回数以下だったらtrue</returns>
16+
public bool Add(DateTime now)
17+
{
18+
const int n = 5;
19+
const int range = 60 * 1000;
20+
_list.Enqueue(now);
21+
if (_list.Count <= n)
22+
{
23+
return true;
24+
}
25+
//直近のn個より前のデータを全て消す
26+
for (int i = _list.Count - n; i > 0; i--)
27+
{
28+
_list.Dequeue();
29+
}
30+
//今あるn個のデータが全て基準時刻移行のものだったらfalseを返す
31+
var baseTime = now.AddMilliseconds(-range);
32+
var b = _list.All(h => h > baseTime);
33+
return !b;
34+
}
35+
public void Reset()
36+
{
37+
_list.Clear();
38+
}
39+
}
940
/// <summary>
1041
/// 複数のIProviderを管理
1142
/// </summary>
@@ -40,8 +71,10 @@ public async Task<ProviderFinishReason> ConnectAsync(IEnumerable<IProvider> grou
4071
{
4172
throw new ArgumentException();
4273
}
74+
_reconnectionCounterDict.Clear();
4375
foreach (var provider in group)
4476
{
77+
_reconnectionCounterDict.Add(provider, new ReconnectionCounter());
4578
provider.Start();
4679
}
4780
var workingProviders = new List<IProvider>(group);
@@ -65,8 +98,11 @@ public async Task<ProviderFinishReason> ConnectAsync(IEnumerable<IProvider> grou
6598
if (!provider.Master.IsFinished)
6699
{
67100
//エラーによる終了が一定時間に一定回数発生したら継続しないようにしたい。
68-
provider.Start();
69-
workingProviders.Add(provider);
101+
if (_reconnectionCounterDict[provider].Add(DateTime.Now))
102+
{
103+
provider.Start();
104+
workingProviders.Add(provider);
105+
}
70106
}
71107
}
72108
}
@@ -98,5 +134,6 @@ public ConnectionManager(ILogger logger)
98134
{
99135
_logger = logger;
100136
}
137+
Dictionary<IProvider, ReconnectionCounter> _reconnectionCounterDict = new Dictionary<IProvider, ReconnectionCounter>();
101138
}
102139
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using NUnit.Framework;
2+
using SitePluginCommon.AutoReconnection;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace SitePluginCommonTests
10+
{
11+
internal class AutoReconnectionTests
12+
{
13+
[Test]
14+
public void Test()
15+
{
16+
var counter = new ReconnectionCounter();
17+
Assert.IsTrue(counter.Add(DateTime.Now));
18+
Assert.IsTrue(counter.Add(DateTime.Now));
19+
Assert.IsTrue(counter.Add(DateTime.Now));
20+
Assert.IsTrue(counter.Add(DateTime.Now));
21+
Assert.IsTrue(counter.Add(DateTime.Now));
22+
Assert.IsFalse(counter.Add(DateTime.Now));
23+
}
24+
}
25+
}

‎TwicasSitePlugin/Message/MessageMetadata.cs‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public Color BackColor
2424
{
2525
return _options.FirstCommentBackColor;
2626
}
27-
else if (_message is ITwicasKiitos)
28-
{
29-
return _siteOptions.KiitosBackColor;
30-
}
3127
else if (_message is ITwicasItem)
3228
{
3329
return _siteOptions.ItemBackColor;
@@ -52,10 +48,6 @@ public Color ForeColor
5248
{
5349
return _options.FirstCommentForeColor;
5450
}
55-
else if (_message is ITwicasKiitos)
56-
{
57-
return _siteOptions.KiitosForeColor;
58-
}
5951
else if (_message is ITwicasItem)
6052
{
6153
return _siteOptions.ItemForeColor;
@@ -197,18 +189,6 @@ private void SiteOptions_PropertyChanged(object sender, System.ComponentModel.Pr
197189
RaisePropertyChanged(nameof(ForeColor));
198190
}
199191
break;
200-
case nameof(_siteOptions.KiitosBackColor):
201-
if (_message is ITwicasKiitos)
202-
{
203-
RaisePropertyChanged(nameof(BackColor));
204-
}
205-
break;
206-
case nameof(_siteOptions.KiitosForeColor):
207-
if (_message is ITwicasKiitos)
208-
{
209-
RaisePropertyChanged(nameof(ForeColor));
210-
}
211-
break;
212192
case nameof(_siteOptions.IsShowItem):
213193
if (_message is ITwicasItem)
214194
{

‎TwicasSitePlugin/TwicasAutoReconnector.cs‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class TwicasAutoReconnector
2020
private readonly ILogger _logger;
2121
private readonly WebsocketMessageProvider _p1;
2222
private readonly MetadataProvider _p2;
23-
2423
public async Task AutoReconnectAsync()
2524
{
2625
_isDisconnectCalled = false;
@@ -37,14 +36,13 @@ public async Task AutoReconnectAsync()
3736
_p1.Cc = _cc;
3837
_p1.BroadcasterId = _broadcasterId;
3938
_p1.LiveId = _currentLiveId ?? liveId;
40-
var nowUnixMillisec = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
41-
_p1.WebsocketUrl = await API.GetWebsocketUrl(_server, _p1.LiveId, nowUnixMillisec, _cc) + "&gift=1";
4239
_p1.Master = _p2;
43-
//var p = new WebsocketMessageProvider(new Common.Websocket());
44-
//p.MessageReceived += (sender, e) => { Debug.WriteLine(e.Raw); };
45-
46-
//var p2 = new MetadataProvider(_logger, _server, _broadcasterId);
47-
40+
Func<Task<string>> f = async () =>
41+
{
42+
var nowUnixMillisec = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
43+
return await API.GetWebsocketUrl(_server, _p1.LiveId, nowUnixMillisec, _cc) + "&gift=1";
44+
};
45+
_p1.GetWsUrl = f;
4846
var reason = await _connectionManager.ConnectAsync(new List<IProvider> { _p1, _p2 });
4947
if (_newLiveStarted)
5048
{
@@ -57,6 +55,20 @@ public async Task AutoReconnectAsync()
5755
}
5856
}
5957
}
58+
59+
private async void _p1_Connecting(object sender, EventArgs e)
60+
{
61+
try
62+
{
63+
var nowUnixMillisec = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
64+
_p1.WebsocketUrl = await API.GetWebsocketUrl(_server, _p1.LiveId, nowUnixMillisec, _cc) + "&gift=1";
65+
}
66+
catch (Exception ex)
67+
{
68+
69+
}
70+
}
71+
6072
bool _isDisconnectCalled;
6173
ConnectionManager _connectionManager;
6274
public void Disconnect()

‎TwicasSitePlugin/TwicasOptionsPanel.xaml‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,11 @@
88
mc:Ignorable="d"
99
d:DesignHeight="450" d:DesignWidth="800">
1010
<Grid>
11-
<Label Content="コメント取得間隔(秒)" HorizontalAlignment="Left" Margin="42,79,0,0" VerticalAlignment="Top"/>
12-
<TextBox HorizontalAlignment="Left" Height="23" Margin="190,82,0,0" TextWrapping="Wrap" Text="{Binding CommentRetrieveIntervalSec}" VerticalAlignment="Top" Width="120" />
13-
<CheckBox Content="@のあとの文字列を自動的にコテハンとして登録する" IsChecked="{Binding IsAutoSetNickname}" HorizontalAlignment="Left" Margin="46,125,0,0" VerticalAlignment="Top"/>
14-
<Label Content="アイテム背景色" HorizontalAlignment="Left" Margin="45,192,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.457,0.731"/>
15-
<xctk:ColorPicker SelectedColor="{Binding ItemBackColor}" Margin="145,192,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" RenderTransformOrigin="3.467,1.727" />
16-
<Label Content="アイテム文字色" HorizontalAlignment="Left" Margin="45,223,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.109,-0.577"/>
17-
<xctk:ColorPicker SelectedColor="{Binding ItemForeColor}" Margin="145,223,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.4,2.591" />
18-
<Label Content="キートス背景色" HorizontalAlignment="Left" Margin="45,254,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.457,0.731"/>
19-
<xctk:ColorPicker SelectedColor="{Binding KiitosBackColor}" Margin="145,258,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" RenderTransformOrigin="3.467,1.727" />
20-
<Label Content="キートス文字色" HorizontalAlignment="Left" Margin="45,285,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.109,-0.577"/>
21-
<xctk:ColorPicker SelectedColor="{Binding KiitosForeColor}" Margin="145,289,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.4,2.591" />
22-
<CheckBox Content="アイテムを表示する" IsChecked="{Binding IsShowItem}" HorizontalAlignment="Left" Margin="46,155,0,0" VerticalAlignment="Top"/>
23-
24-
11+
<CheckBox Content="@のあとの文字列を自動的にコテハンとして登録する" IsChecked="{Binding IsAutoSetNickname}" HorizontalAlignment="Left" Margin="45,50,0,0" VerticalAlignment="Top"/>
12+
<Label Content="アイテム背景色" HorizontalAlignment="Left" Margin="45,103,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.457,0.731"/>
13+
<xctk:ColorPicker SelectedColor="{Binding ItemBackColor}" Margin="145,103,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" RenderTransformOrigin="3.467,1.727" />
14+
<Label Content="アイテム文字色" HorizontalAlignment="Left" Margin="45,134,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.109,-0.577"/>
15+
<xctk:ColorPicker SelectedColor="{Binding ItemForeColor}" Margin="145,134,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.4,2.591" />
16+
<CheckBox Content="アイテムを表示する" IsChecked="{Binding IsShowItem}" HorizontalAlignment="Left" Margin="45,70,0,0" VerticalAlignment="Top"/>
2517
</Grid>
2618
</UserControl>

‎TwicasSitePlugin/TwicasSiteOptions.cs‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,15 @@
1111

1212
namespace TwicasSitePlugin
1313
{
14-
interface ITwicasSiteOptions:INotifyPropertyChanged
14+
interface ITwicasSiteOptions:INotifyPropertyChanged
1515
{
16-
int CommentRetrieveIntervalSec { get; set; }
17-
Color KiitosBackColor { get; set; }
18-
Color KiitosForeColor { get; set; }
1916
bool IsAutoSetNickname { get; set; }
2017
Color ItemBackColor { get; set; }
2118
Color ItemForeColor { get; set; }
2219
bool IsShowItem { get; set; }
2320
}
2421
internal class TwicasSiteOptions : DynamicOptionsBase, ITwicasSiteOptions
2522
{
26-
//コメント取得インターバル
27-
public int CommentRetrieveIntervalSec { get => GetValue(); set => SetValue(value); }
28-
//キートス
29-
public Color KiitosBackColor { get => GetValue(); set => SetValue(value); }
30-
public Color KiitosForeColor { get => GetValue(); set => SetValue(value); }
3123

3224
public Color ItemBackColor { get => GetValue(); set => SetValue(value); }
3325
public Color ItemForeColor { get => GetValue(); set => SetValue(value); }
@@ -36,9 +28,6 @@ internal class TwicasSiteOptions : DynamicOptionsBase, ITwicasSiteOptions
3628
public bool IsShowItem { get => GetValue(); set => SetValue(value); }
3729
protected override void Init()
3830
{
39-
Dict.Add(nameof(CommentRetrieveIntervalSec), new Item { DefaultValue = 1, Predicate = f => f > 0, Serializer = f => f.ToString(), Deserializer = s => int.Parse(s) });
40-
Dict.Add(nameof(KiitosBackColor), new Item { DefaultValue = ColorFromArgb("#FFFF0000"), Predicate = c => true, Serializer = c => ColorToArgb(c), Deserializer = s => ColorFromArgb(s) });
41-
Dict.Add(nameof(KiitosForeColor), new Item { DefaultValue = ColorFromArgb("#FFFFFFFF"), Predicate = c => true, Serializer = c => ColorToArgb(c), Deserializer = s => ColorFromArgb(s) });
4231
Dict.Add(nameof(ItemBackColor), new Item { DefaultValue = ColorFromArgb("#FFFF0000"), Predicate = c => true, Serializer = c => ColorToArgb(c), Deserializer = s => ColorFromArgb(s) });
4332
Dict.Add(nameof(ItemForeColor), new Item { DefaultValue = ColorFromArgb("#FFFFFFFF"), Predicate = c => true, Serializer = c => ColorToArgb(c), Deserializer = s => ColorFromArgb(s) });
4433
Dict.Add(nameof(IsAutoSetNickname), new Item { DefaultValue = false, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });

‎TwicasSitePlugin/TwicasSiteOptionsViewModel.cs‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ namespace TwicasSitePlugin
66
{
77
class TwicasSiteOptionsViewModel : INotifyPropertyChanged
88
{
9-
public int CommentRetrieveIntervalSec
10-
{
11-
get { return ChangedOptions.CommentRetrieveIntervalSec; }
12-
set { ChangedOptions.CommentRetrieveIntervalSec = value; }
13-
}
14-
public Color KiitosBackColor
15-
{
16-
get { return ChangedOptions.KiitosBackColor; }
17-
set { ChangedOptions.KiitosBackColor = value; }
18-
}
19-
public Color KiitosForeColor
20-
{
21-
get { return ChangedOptions.KiitosForeColor; }
22-
set { ChangedOptions.KiitosForeColor = value; }
23-
}
249
public Color ItemBackColor
2510
{
2611
get { return ChangedOptions.ItemBackColor; }

‎TwicasSitePlugin/WebsocketMessageProvider.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ class WebsocketMessageProvider : IProvider
4949
public string BroadcasterId { get; set; }
5050
public long LiveId { get; set; }
5151
public string WebsocketUrl { get; set; }
52+
public Func<Task<string>> GetWsUrl { get; set; }
5253
private async Task ConnectAsync()
5354
{
54-
await _websocket.ReceiveAsync(WebsocketUrl);
55+
var url = await GetWsUrl();
56+
await _websocket.ReceiveAsync(url);
5557
}
5658
public WebsocketMessageProvider(IWebsocket websocket, IDataServer server)
5759
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /