Skip to content

Commit 9e16ef4

Browse files
authored
Merge pull request #99 from ptkNktq/fix/desktop_app
デスクトップアプリ側修正
2 parents 0503cae + 06f1d31 commit 9e16ef4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

DesktopApp/AndroidNotificationNotifier.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<Nullable>enable</Nullable>
77
<UseWPF>true</UseWPF>
88
<UseWindowsForms>true</UseWindowsForms>
9+
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
910
</PropertyGroup>
1011

1112
<ItemGroup>

DesktopApp/App.xaml.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ private void StartApp()
4040
var settings = JsonSerializer.Deserialize<Settings>(json);
4141
if (settings == null)
4242
{
43-
throw new Exception("設定ファイルを読み込めませんでした。修正して再起動してください。");
43+
Notify("設定ファイルを読み込めませんでした。修正して再起動してください。");
44+
return;
4445
}
4546
var ep = new IPEndPoint(IPAddress.Any, settings.Port);
4647
server = new TcpListener(ep);
@@ -49,17 +50,14 @@ private void StartApp()
4950
while (true)
5051
{
5152
using TcpClient client = server.AcceptTcpClient();
52-
var stream = client.GetStream();
53-
int i;
54-
while ((i = stream.Read(buff, 0, buff.Length)) != 0)
55-
{
56-
var message = Encoding.UTF8.GetString(buff);
57-
Notify(message);
58-
}
53+
using StreamReader reader = new (client.GetStream(), Encoding.UTF8);
54+
var message = reader.ReadToEnd();
55+
Notify(message);
56+
Array.Clear(buff, 0, buff.Length);
5957
client.Close();
6058
}
6159
}
62-
catch (Exception e)
60+
catch (SocketException e)
6361
{
6462
Notify($"エラー: {e.Message}");
6563
}

0 commit comments

Comments
 (0)