File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 66 <Nullable >enable</Nullable >
77 <UseWPF >true</UseWPF >
88 <UseWindowsForms >true</UseWindowsForms >
9+ <ApplicationIcon >Resources\icon.ico</ApplicationIcon >
910 </PropertyGroup >
1011
1112 <ItemGroup >
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments