trying to fix avalonia

This commit is contained in:
Timerix22 2022-07-01 19:36:38 +03:00
parent 9e0f9ad1a6
commit 0eab3ba8f3
38 changed files with 222 additions and 241 deletions

View File

@ -5,7 +5,7 @@ VisualStudioVersion = 17.1.32104.313
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-server", "launcher-server\launcher-server.csproj", "{1F4D14EB-AF48-4B6C-A91B-B294D4281173}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-server", "launcher-server\launcher-server.csproj", "{1F4D14EB-AF48-4B6C-A91B-B294D4281173}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-client-win", "launcher-client-win\launcher-client-win.csproj", "{A1F770F3-F6B1-4854-9BF0-093F85064B88}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "launcher-client-wpf", "launcher-client-wpf\launcher-client-wpf.csproj", "{A1F770F3-F6B1-4854-9BF0-093F85064B88}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{F567AA49-E96B-43BD-95B5-A71F9FCB64E1}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{F567AA49-E96B-43BD-95B5-A71F9FCB64E1}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject

View File

@ -1,4 +1,4 @@
<Application x:Class="launcher_client_avalonia.GUI.App" <Application x:Class="Launcher.Client.Avalonia.GUI.App"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources> <Application.Resources>
@ -12,13 +12,13 @@
<SolidColorBrush x:Key="MyRed" Color="#E5160A" /> <SolidColorBrush x:Key="MyRed" Color="#E5160A" />
<SolidColorBrush x:Key="MySelectionColor" Color="#B7800A" /> <SolidColorBrush x:Key="MySelectionColor" Color="#B7800A" />
</Application.Resources> </Application.Resources>
<Application.Styles> <Application.Styles>
<FluentTheme Mode="Dark" /> <FluentTheme Mode="Dark" />
<Style x:Name="MyTextBoxStyle" Selector="TextBox.MyTextBoxStyle"/> <Style Selector="TextBox.MyTextBoxStyle" />
<Style x:Name="MyLabelStyle" Selector="Label.MyLabelStyle"/> <Style Selector="Label.MyLabelStyle" />
<Style x:Name="MyButtonStyle" Selector="Button.MyButtonStyle"/> <Style Selector="Button.MyButtonStyle" />
</Application.Styles> </Application.Styles>
</Application> </Application>

View File

@ -3,8 +3,9 @@ global using Avalonia.Controls;
global using Avalonia.Media; global using Avalonia.Media;
global using Avalonia.Media.Imaging; global using Avalonia.Media.Imaging;
global using Avalonia.Markup.Xaml; global using Avalonia.Markup.Xaml;
using Avalonia.Controls.ApplicationLifetimes;
namespace launcher_client_avalonia namespace Launcher.Client.Avalonia.GUI
{ {
public partial class App : Application public partial class App : Application
{ {
@ -20,5 +21,18 @@ namespace launcher_client_avalonia
MyOrange = (SolidColorBrush)Resources["MySelectionColor"]; MyOrange = (SolidColorBrush)Resources["MySelectionColor"];
MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"]; MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"];
} }
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
CurrentLauncherWindow = new LauncherWindow();
desktop.MainWindow = CurrentLauncherWindow;
CurrentLauncherWindow.Show();
}
base.OnFrameworkInitializationCompleted();
}
} }
} }

View File

@ -1,7 +1,7 @@
<Window x:Class="launcher_client_avalonia.GUI.LauncherWindow" <Window x:Class="Launcher.Client.Avalonia.GUI.LauncherWindow"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:launcher_client_avalonia.GUI" xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
Title="Launcher" Title="Launcher"
Width="800" Width="800"
Height="500" Height="500"
@ -21,24 +21,24 @@
ColumnDefinitions="*,5,*,5,*,5,*"> ColumnDefinitions="*,5,*,5,*,5,*">
<local:TabButton x:Name="LibraryButton" <local:TabButton x:Name="LibraryButton"
Grid.Column="0" Grid.Column="0"
Classes="MyButtonStyle"
Content="Library" Content="Library"
FontSize="18" FontSize="18" />
Classes="MyButtonStyle" />
<local:TabButton x:Name="DownloadsButton" <local:TabButton x:Name="DownloadsButton"
Grid.Column="2" Grid.Column="2"
Classes="MyButtonStyle"
Content="Downloads" Content="Downloads"
FontSize="18" FontSize="18" />
Classes="MyButtonStyle" />
<local:TabButton x:Name="LogButton" <local:TabButton x:Name="LogButton"
Grid.Column="4" Grid.Column="4"
Classes="MyButtonStyle"
Content="Log" Content="Log"
FontSize="18" FontSize="18" />
Classes="MyButtonStyle" />
<local:TabButton x:Name="SettingsButton" <local:TabButton x:Name="SettingsButton"
Grid.Column="6" Grid.Column="6"
Classes="MyButtonStyle"
Content="Settings" Content="Settings"
FontSize="18" FontSize="18" />
Classes="MyButtonStyle" />
</Grid> </Grid>
@ -50,8 +50,8 @@
<ScrollViewer Grid.Column="0" <ScrollViewer Grid.Column="0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
ScrollViewer.VerticalScrollBarVisibility="Auto" Template="{DynamicResource myScrollViewer}"
Template="{DynamicResource myScrollViewer}"> VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="ProgramsPanel" /> <StackPanel x:Name="ProgramsPanel" />
</ScrollViewer> </ScrollViewer>
<Grid x:Name="ProgramGrid" <Grid x:Name="ProgramGrid"
@ -59,10 +59,10 @@
RowDefinitions="35,5,35,5,70,5,*"> RowDefinitions="35,5,35,5,70,5,*">
<Label x:Name="NameLabel" <Label x:Name="NameLabel"
Grid.Row="0" Grid.Row="0"
Classes="MyLabelStyle"
Content="name" Content="name"
FontSize="19" FontSize="19"
FontWeight="Bold" FontWeight="Bold" />
Classes="MyLabelStyle" />
<StackPanel Grid.Row="2" <StackPanel Grid.Row="2"
HorizontalAlignment="Right" HorizontalAlignment="Right"
ClipToBounds="True" ClipToBounds="True"
@ -71,33 +71,33 @@
Width="100" Width="100"
Margin="2,0" Margin="2,0"
Background="{DynamicResource MyRed}" Background="{DynamicResource MyRed}"
Content="Remove" Classes="MyButtonStyle"
Classes="MyButtonStyle" /> Content="Remove" />
<Button x:Name="InstallButton" <Button x:Name="InstallButton"
Width="100" Width="100"
Margin="2,0" Margin="2,0"
Content="Install" Classes="MyButtonStyle"
Classes="MyButtonStyle" /> Content="Install" />
<Button x:Name="UpdateButton" <Button x:Name="UpdateButton"
Width="100" Width="100"
Margin="2,0" Margin="2,0"
Content="Update" Classes="MyButtonStyle"
Classes="MyButtonStyle" /> Content="Update" />
<Button x:Name="LaunchButton" <Button x:Name="LaunchButton"
Width="100" Width="100"
Margin="2,0" Margin="2,0"
Background="{DynamicResource MyGreen}" Background="{DynamicResource MyGreen}"
Content="Launch" Classes="MyButtonStyle"
Classes="MyButtonStyle" /> Content="Launch" />
</StackPanel> </StackPanel>
<TextBox x:Name="DescriptionBox" <TextBox x:Name="DescriptionBox"
Grid.Row="4" Grid.Row="4"
ScrollViewer.VerticalScrollBarVisibility="Auto" Classes="MyTextBoxStyle"
Classes="MyTextBoxStyle" /> ScrollViewer.VerticalScrollBarVisibility="Auto" />
<TextBox x:Name="ProgramLogBox" <TextBox x:Name="ProgramLogBox"
Grid.Row="6" Grid.Row="6"
ScrollViewer.VerticalScrollBarVisibility="Auto" Classes="MyTextBoxStyle"
Classes="MyTextBoxStyle" /> ScrollViewer.VerticalScrollBarVisibility="Auto" />
</Grid> </Grid>
<Grid Grid.Row="0" <Grid Grid.Row="0"
Grid.Column="4" Grid.Column="4"
@ -108,36 +108,36 @@
<Label Grid.Row="0" <Label Grid.Row="0"
Grid.Column="0" Grid.Column="0"
Content="version:" Classes="MyLabelStyle"
Classes="MyLabelStyle" /> Content="version:" />
<ComboBox Grid.Row="0" <ComboBox Grid.Row="0"
Grid.Column="1" Grid.Column="1"
Background="{DynamicResource MyDarkTr}" Background="{DynamicResource MyDarkTr}"
Template="{DynamicResource MyComboBox}"> Template="{DynamicResource MyComboBox}">
<ComboBoxItem IsSelected="True"> <ComboBoxItem IsSelected="True">
<Label Background="Transparent" <Label Background="Transparent"
Content="v1" Classes="MyLabelStyle"
Classes="MyLabelStyle" /> Content="v1" />
</ComboBoxItem> </ComboBoxItem>
</ComboBox> </ComboBox>
<Label Grid.Row="1" <Label Grid.Row="1"
Grid.Column="0" Grid.Column="0"
Content="directory:" Classes="MyLabelStyle"
Classes="MyLabelStyle" /> Content="directory:" />
<Label Name="ProgramDirectoryLabel" <Label Name="ProgramDirectoryLabel"
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Content="0" Classes="MyLabelStyle"
Classes="MyLabelStyle" /> Content="0" />
<Label Grid.Row="2" <Label Grid.Row="2"
Grid.Column="0" Grid.Column="0"
Content="size:" Classes="MyLabelStyle"
Classes="MyLabelStyle" /> Content="size:" />
<Label Name="ProgramSizeLabel" <Label Name="ProgramSizeLabel"
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Content="0" Classes="MyLabelStyle"
Classes="MyLabelStyle" /> Content="0" />
</Grid> </Grid>
<ScrollViewer Name="ProgramSettingsViever" <ScrollViewer Name="ProgramSettingsViever"
Grid.Row="1" Grid.Row="1"
@ -162,14 +162,14 @@
<Label x:Name="LogfileLabel" <Label x:Name="LogfileLabel"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
Classes="MyLabelStyle"
Content="logfile" Content="logfile"
FontStyle="Italic" FontStyle="Italic" />
Classes="MyLabelStyle" />
<TextBox x:Name="LogBox" <TextBox x:Name="LogBox"
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
ScrollViewer.VerticalScrollBarVisibility="Auto" Classes="MyTextBoxStyle"
Classes="MyTextBoxStyle" /> ScrollViewer.VerticalScrollBarVisibility="Auto" />
</Grid> </Grid>
<Grid x:Name="SettingsGrid" <Grid x:Name="SettingsGrid"

View File

@ -1,7 +1,7 @@
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Threading; using Avalonia.Threading;
namespace launcher_client_avalonia.GUI; namespace Launcher.Client.Avalonia.GUI;
public partial class LauncherWindow : Window public partial class LauncherWindow : Window
{ {
@ -9,12 +9,12 @@ public partial class LauncherWindow : Window
{ {
try try
{ {
AvaloniaXamlLoader.Load(this); InitializeComponent();
LogBox.Text = Logger.Buffer; LogBox.Text = Logger.Buffer;
Logger.MessageSent += LogHandler; Logger.MessageSent += LogHandler;
LogfileLabel.Content = Logger.Logfile.Remove(0,Logger.Logfile.LastIndexOf(Путь.Разд)+1); LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
LogfileLabel.PointerPressed += (_,_)=> LogfileLabel.PointerPressed += (_,_)=>
Process.Start("explorer.exe", Logger.Logfile.Remove(Logger.Logfile.LastIndexOf(Путь.Разд))); Process.Start("explorer.exe", LauncherLogger.LogfileDir);
LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor; LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite; LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
LibraryButton.TabGrid = LibraryGrid; LibraryButton.TabGrid = LibraryGrid;

View File

@ -1,4 +1,4 @@
<Window x:Class="launcher_client_avalonia.GUI.MessageBox" <Window x:Class="Launcher.Client.Avalonia.GUI.MessageBox"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

View File

@ -1,10 +1,10 @@
namespace launcher_client_avalonia.GUI; namespace Launcher.Client.Avalonia.GUI;
public partial class MessageBox : Window public partial class MessageBox : Window
{ {
public MessageBox() public MessageBox()
{ {
AvaloniaXamlLoader.Load(this); InitializeComponent();
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();
#endif #endif

View File

@ -1,7 +1,7 @@
<UserControl x:Class="launcher_client_avalonia.GUI.ProgramLabel" <UserControl x:Class="Launcher.Client.Avalonia.GUI.ProgramLabel"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:launcher_client_avalonia.GUI" xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
Height="50" Height="50"
Background="{DynamicResource MyDarkTr}" Background="{DynamicResource MyDarkTr}"
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource Self}}" BorderBrush="{Binding Foreground, RelativeSource={RelativeSource Self}}"
@ -9,7 +9,7 @@
Foreground="{DynamicResource MyWhite}"> Foreground="{DynamicResource MyWhite}">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Height, RelativeSource={RelativeSource FindAncestor, AncestorType=local:ProgramLabel}}" /> <ColumnDefinition Width="{Binding $parent[local:ProgramLabel].Height}" />
<ColumnDefinition /> <ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -25,6 +25,6 @@
FontFamily="Unispace" FontFamily="Unispace"
FontSize="15" FontSize="15"
FontWeight="Normal" FontWeight="Normal"
Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramLabel}}" /> Foreground="{Binding $parent[local:ProgramLabel].Foreground}" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,12 +1,13 @@
namespace launcher_client_avalonia.GUI; namespace Launcher.Client.Avalonia.GUI;
public partial class ProgramLabel : UserControl public partial class ProgramLabel : UserControl
{ {
public ProgramLabel() => InitializeComponent();
public ProgramLabel(string label, string icon) public ProgramLabel(string label, string icon)
{ {
AvaloniaXamlLoader.Load(this); InitializeComponent();
NameLabel.Content = label; NameLabel.Content = label;
IconImage.Source = new Bitmap( IconImage.Source = new Bitmap(
$"{Directory.GetCurrent()}{Путь.Разд}icons{Путь.Разд}{icon}"); $"{Directory.GetCurrent()}{Путь.Разд}icons{Путь.Разд}{icon}");
} }

View File

@ -1,23 +1,22 @@
<UserControl x:Class="launcher_client_avalonia.GUI.ProgramSettingsPanelItem" <UserControl x:Class="Launcher.Client.Avalonia.GUI.ProgramSettingsPanelItem"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:launcher_client_avalonia.GUI" xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
Background="Transparent"> Background="Transparent">
<Grid ColumnDefinitions="*,*"> <Grid ColumnDefinitions="*,*">
<Label Name="KeyLabel" <Label Name="KeyLabel"
Grid.Column="0" Grid.Column="0"
Classes="MyLabelStyle"
Content="{Binding $parent[local:ProgramSettingsPanelItem].SettingKey}" Content="{Binding $parent[local:ProgramSettingsPanelItem].SettingKey}"
FontFamily="default" FontFamily="default"
FontSize="16" FontSize="16"
Classes="MyLabelStyle" ToolTip.Tip="{Binding $self.Content}" />
ToolTip.Tip="{Binding $self.Content}">
</Label>
<TextBox Name="ValueBox" <TextBox Name="ValueBox"
Grid.Column="1" Grid.Column="1"
Classes="MyTextBoxStyle"
IsReadOnly="False" IsReadOnly="False"
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"
Classes="MyTextBoxStyle"
Text="{Binding $parent[local:ProgramSettingsPanelItem].SettingValue}" /> Text="{Binding $parent[local:ProgramSettingsPanelItem].SettingValue}" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,4 +1,4 @@
namespace launcher_client_avalonia.GUI; namespace Launcher.Client.Avalonia.GUI;
public partial class ProgramSettingsPanelItem : UserControl public partial class ProgramSettingsPanelItem : UserControl
{ {
@ -7,32 +7,32 @@ public partial class ProgramSettingsPanelItem : UserControl
"SettingKey"); "SettingKey");
public string SettingKey public string SettingKey
{ {
get => (string)GetValue(SettingKeyProp); get => GetValue(SettingKeyProp);
set set => SetValue(SettingKeyProp, value);
{ //TODO deal with textblock size
SetValue(SettingKeyProp, value); /*KeyLabel.ToolTip = new ToolTip
/*KeyLabel.ToolTip = new ToolTip
{ {
Content = value, Content = value,
Foreground = App.MyWhite, Foreground = App.MyWhite,
Background = App.MySoftDark Background = App.MySoftDark
};*/ };*/
}
} }
public static readonly StyledProperty<string> SettingValueProp = public static readonly StyledProperty<string> SettingValueProp =
AvaloniaProperty.Register<ProgramSettingsPanelItem, string>("SettingValue"); AvaloniaProperty.Register<ProgramSettingsPanelItem, string>("SettingValue");
public string SettingValue public string SettingValue
{ {
get => (string)GetValue(SettingValueProp); get => GetValue(SettingValueProp);
set => SetValue(SettingValueProp, value); set => SetValue(SettingValueProp, value);
} }
public event Action<ProgramSettingsPanelItem> UpdatedEvent; public event Action<ProgramSettingsPanelItem> UpdatedEvent;
public ProgramSettingsPanelItem() => InitializeComponent();
public ProgramSettingsPanelItem(string key, string value) public ProgramSettingsPanelItem(string key, string value)
{ {
AvaloniaXamlLoader.Load(this); InitializeComponent();
SettingKey = key; SettingKey = key;
SettingValue = value; SettingValue = value;
//TODO invoke UpdatedEvent only when focus changed //TODO invoke UpdatedEvent only when focus changed

View File

@ -1,11 +1,11 @@
namespace launcher_client_avalonia.GUI; namespace Launcher.Client.Avalonia.GUI;
public partial class TabButton : Button public class TabButton : Button
{ {
public static readonly StyledProperty<Grid> TabGridProp = AvaloniaProperty.Register<TabButton, Grid>("TabGrid"); public static readonly StyledProperty<Grid> TabGridProp = AvaloniaProperty.Register<TabButton, Grid>("TabGrid");
public Grid TabGrid public Grid TabGrid
{ {
get => (Grid)GetValue(TabGridProp); get => GetValue(TabGridProp);
set => SetValue(TabGridProp, value); set => SetValue(TabGridProp, value);
} }
} }

View File

@ -1,4 +1,4 @@
namespace launcher_client_avalonia; namespace Launcher.Client.Avalonia;
public class LauncherConfig public class LauncherConfig
{ {
@ -21,7 +21,7 @@ public class LauncherConfig
{ {
// читает дефолтный конфиг из ресурсов // читает дефолтный конфиг из ресурсов
DtsodV23 updatedConfig; DtsodV23 updatedConfig;
DtsodV23 updatedDefault = new(ReadResource("launcher_client_avalonia.Resources.launcher.dtsod")); DtsodV23 updatedDefault = new(EmbeddedResources.ReadText("Launcher.Client.Avalonia.Resources.launcher.dtsod"));
// проверка и обновление конфига // проверка и обновление конфига
if (File.Exists(configFile)) if (File.Exists(configFile))
{ {

View File

@ -1,36 +1,31 @@
using System.Globalization; using DTLib.Loggers;
using DTLib.Loggers;
namespace launcher_client_avalonia; namespace Launcher.Client.Avalonia;
public class LauncherLogger : BaseLogger public class LauncherLogger : ConsoleLogger
{ {
public string Buffer=""; public const string LogfileDir = "launcher-logs";
public LauncherLogger() : base(LogfileDir,"launcher-client-wpf")
public LauncherLogger() : base("launcher-logs", "launcher-client-win")
{ } { }
private readonly StringBuilder _buffer = new();
public string Buffer
{
get { lock (_buffer) return _buffer.ToString(); }
}
public event Action<string> MessageSent; public event Action<string> MessageSent;
public override void Log(params string[] msg) public override void Log(params string[] msg)
{ {
lock (Logfile) if (!IsEnabled) return; base.Log(msg);
StringBuilder strb = new();
StringBuilder strB = new(); if (msg.Length == 1) strb.Append(msg[0]);
strB.Append('[') else for (int i = 1; i < msg.Length; i += 2)
.Append(DateTime.Now.ToString(CultureInfo.InvariantCulture)) strb.Append(msg[i]);
.Append("]: "); strb.Append('\n');
if (msg.Length == 1) strB.Append(msg[0]); string msgConnected = strb.ToString();
else for (ushort i = 0; i < msg.Length; i++) MessageSent?.Invoke(msgConnected);
strB.Append(msg[++i]); lock (_buffer) _buffer.Append(msgConnected);
strB.Append('\n');
string _buffer = strB.ToString();
lock(Buffer) Buffer += _buffer;
MessageSent?.Invoke(_buffer);
if (WriteToFile)
lock(Logfile) File.AppendAllText(Logfile, _buffer);
} }
} }

View File

@ -8,13 +8,12 @@ global using DTLib;
global using DTLib.Dtsod; global using DTLib.Dtsod;
global using DTLib.Filesystem; global using DTLib.Filesystem;
global using DTLib.Extensions; global using DTLib.Extensions;
global using static launcher_client_avalonia.Launcher; global using static Launcher.Client.Avalonia.LauncherMain;
using System.Reflection; using Launcher.Client.Avalonia.GUI;
using launcher_client_avalonia.GUI;
namespace launcher_client_avalonia; namespace Launcher.Client.Avalonia;
public static class Launcher public static class LauncherMain
{ {
public static LauncherConfig Config; public static LauncherConfig Config;
public static readonly LauncherLogger Logger = new(); public static readonly LauncherLogger Logger = new();
@ -24,15 +23,6 @@ public static class Launcher
{ {
try try
{ {
Logger.Enable();
AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.StartWithClassicDesktopLifetime(args);
CurrentLauncherWindow = new LauncherWindow();
CurrentLauncherWindow.Show();
Config = new LauncherConfig(); Config = new LauncherConfig();
Directory.Create("descriptors"); Directory.Create("descriptors");
Directory.Create("icons"); Directory.Create("icons");
@ -40,8 +30,16 @@ public static class Launcher
Directory.Create("installed"); Directory.Create("installed");
Directory.Create("settings"); Directory.Create("settings");
File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template", File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template",
ReadResource("launcher_client_avalonia.Resources.default.descriptor.template")); EmbeddedResources.ReadText("Launcher.Client.Avalonia.Resources.default.descriptor.template"));
var traceHandler = new ConsoleTraceListener();
Trace.AutoFlush = true;
Trace.Listeners.Add(traceHandler);
AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.StartWithClassicDesktopLifetime(args);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -49,19 +47,10 @@ public static class Launcher
} }
} }
public static string ReadResource(string resource_path)
{
using var resourceStreamReader = new System.IO.StreamReader(
Assembly.GetExecutingAssembly().GetManifestResourceStream(resource_path)
?? throw new Exception($"embedded resource <{resource_path}> not found"),
Encoding.UTF8);
return resourceStreamReader.ReadToEnd();
}
public static void LogError(string context, Exception ex) public static void LogError(string context, Exception ex)
{ {
string errmsg = $"{ex.Message}\n{ex.StackTrace}"; string errmsg = $"{ex.Message}\n{ex.StackTrace}";
MessageBox.Show($"{context} ERROR", errmsg); //MessageBox.Show($"{context} ERROR", errmsg);
Logger.Log(errmsg); Logger.Log(errmsg);
} }
} }

View File

@ -1,6 +1,6 @@
using launcher_client_avalonia.GUI; using Launcher.Client.Avalonia.GUI;
namespace launcher_client_avalonia; namespace Launcher.Client.Avalonia;
public class Program public class Program
{ {

View File

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>Launcher.Client.Avalonia</RootNamespace>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>

View File

@ -1,36 +0,0 @@
using System.Globalization;
using DTLib.Loggers;
namespace launcher_client_win;
public class LauncherLogger : BaseLogger
{
public string Buffer="";
public LauncherLogger() : base("launcher-logs", "launcher-client-win")
{ }
public event Action<string> MessageSent;
public override void Log(params string[] msg)
{
lock (Logfile) if (!IsEnabled) return;
StringBuilder strB = new();
strB.Append('[')
.Append(DateTime.Now.ToString(CultureInfo.InvariantCulture))
.Append("]: ");
if (msg.Length == 1) strB.Append(msg[0]);
else for (ushort i = 0; i < msg.Length; i++)
strB.Append(msg[++i]);
strB.Append('\n');
string _buffer = strB.ToString();
lock(Buffer) Buffer += _buffer;
MessageSent?.Invoke(_buffer);
if (WriteToFile)
lock(Logfile) File.AppendAllText(Logfile, _buffer);
}
}

View File

@ -1,4 +1,4 @@
<Application x:Class="launcher_client_win.GUI.App" <Application x:Class="Launcher.Client.WPF.GUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources> <Application.Resources>

View File

@ -1,6 +1,6 @@
using System.Windows.Media; using System.Windows.Media;
namespace launcher_client_win.GUI; namespace Launcher.Client.WPF.GUI;
public partial class App : Application public partial class App : Application
{ {

View File

@ -1,8 +1,8 @@
<Window x:Class="launcher_client_win.GUI.LauncherWindow" <Window x:Class="Launcher.Client.WPF.GUI.LauncherWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:launcher_client_win.GUI" xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Launcher" Title="Launcher"
Width="800" Width="800"

View File

@ -1,6 +1,6 @@
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
namespace launcher_client_win.GUI; namespace Launcher.Client.WPF.GUI;
public partial class LauncherWindow : Window public partial class LauncherWindow : Window
{ {
@ -11,11 +11,11 @@ public partial class LauncherWindow : Window
InitializeComponent(); InitializeComponent();
LogBox.Text = Logger.Buffer; LogBox.Text = Logger.Buffer;
Logger.MessageSent += LogHandler; Logger.MessageSent += LogHandler;
LogfileLabel.Content = Logger.Logfile.Remove(0,Logger.Logfile.LastIndexOf(Путь.Разд)+1); LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
LogfileLabel.MouseLeftButtonDown += (s,e)=> LogfileLabel.MouseLeftButtonDown += (_,_)=>
Process.Start("explorer.exe", Logger.Logfile.Remove(Logger.Logfile.LastIndexOf(Путь.Разд))); Process.Start("explorer.exe", LauncherLogger.LogfileDir);
LogfileLabel.MouseEnter += (s,e)=>LogfileLabel.Foreground=App.MySelectionColor; LogfileLabel.MouseEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
LogfileLabel.MouseLeave += (s,e)=>LogfileLabel.Foreground=App.MyWhite; LogfileLabel.MouseLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
LibraryButton.TabGrid = LibraryGrid; LibraryButton.TabGrid = LibraryGrid;
DownloadsButton.TabGrid = DownloadsGrid; DownloadsButton.TabGrid = DownloadsGrid;
LogButton.TabGrid = LogGrid; LogButton.TabGrid = LogGrid;

View File

@ -1,8 +1,8 @@
<UserControl x:Class="launcher_client_win.GUI.ProgramLabel" <UserControl x:Class="Launcher.Client.WPF.GUI.ProgramLabel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:launcher_client_win.GUI" xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Height="50" Height="50"
Background="{DynamicResource MyDarkTr}" Background="{DynamicResource MyDarkTr}"

View File

@ -1,7 +1,7 @@
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
namespace launcher_client_win.GUI; namespace Launcher.Client.WPF.GUI;
public partial class ProgramLabel : UserControl public partial class ProgramLabel : UserControl
{ {

View File

@ -1,8 +1,8 @@
<UserControl x:Class="launcher_client_win.GUI.ProgramSettingsPanelItem" <UserControl x:Class="Launcher.Client.WPF.GUI.ProgramSettingsPanelItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:launcher_client_win.GUI" xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignWidth="100" d:DesignWidth="100"
d:DesignHeight="30" d:DesignHeight="30"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace launcher_client_win.GUI; namespace Launcher.Client.WPF.GUI;
public partial class ProgramSettingsPanelItem : UserControl public partial class ProgramSettingsPanelItem : UserControl
{ {

View File

@ -1,6 +1,6 @@
using System.Windows.Controls; using System.Windows.Controls;
namespace launcher_client_win.GUI; namespace Launcher.Client.WPF.GUI;
public class TabButton : Button public class TabButton : Button
{ {

View File

@ -1,4 +1,4 @@
namespace launcher_client_win; namespace Launcher.Client.WPF;
public class LauncherConfig public class LauncherConfig
{ {
@ -21,7 +21,7 @@ public class LauncherConfig
{ {
// читает дефолтный конфиг из ресурсов // читает дефолтный конфиг из ресурсов
DtsodV23 updatedConfig; DtsodV23 updatedConfig;
DtsodV23 updatedDefault = new(ReadResource("launcher_client_win.Resources.launcher.dtsod")); DtsodV23 updatedDefault = new(EmbeddedResources.ReadText("Launcher.Client.WPF.Resources.launcher.dtsod"));
// проверка и обновление конфига // проверка и обновление конфига
if (File.Exists(configFile)) if (File.Exists(configFile))
{ {

View File

@ -0,0 +1,31 @@
using DTLib.Loggers;
namespace Launcher.Client.WPF;
public class LauncherLogger : ConsoleLogger
{
public const string LogfileDir = "launcher-logs";
public LauncherLogger() : base(LogfileDir,"launcher-client-wpf")
{ }
private readonly StringBuilder _buffer = new();
public string Buffer
{
get { lock (_buffer) return _buffer.ToString(); }
}
public event Action<string> MessageSent;
public override void Log(params string[] msg)
{
base.Log(msg);
StringBuilder strb = new();
if (msg.Length == 1) strb.Append(msg[0]);
else for (int i = 1; i < msg.Length; i += 2)
strb.Append(msg[i]);
strb.Append('\n');
string msgConnected = strb.ToString();
MessageSent?.Invoke(msgConnected);
lock (_buffer) _buffer.Append(msgConnected);
}
}

View File

@ -7,16 +7,14 @@ global using System.Diagnostics;
global using System.Net; global using System.Net;
global using System.Text; global using System.Text;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.Threading;
global using System.Linq; global using System.Linq;
global using System.Windows; global using System.Windows;
global using static launcher_client_win.Launcher; global using static Launcher.Client.WPF.LauncherMain;
using System.Reflection; using Launcher.Client.WPF.GUI;
using launcher_client_win.GUI;
namespace launcher_client_win; namespace Launcher.Client.WPF;
public static class Launcher public static class LauncherMain
{ {
public static LauncherConfig Config; public static LauncherConfig Config;
public static readonly LauncherLogger Logger = new(); public static readonly LauncherLogger Logger = new();
@ -24,7 +22,6 @@ public static class Launcher
public static void _Main(string[] args) public static void _Main(string[] args)
{ {
Logger.Enable();
Config = new LauncherConfig(); Config = new LauncherConfig();
Directory.Create("descriptors"); Directory.Create("descriptors");
Directory.Create("icons"); Directory.Create("icons");
@ -32,19 +29,10 @@ public static class Launcher
Directory.Create("installed"); Directory.Create("installed");
Directory.Create("settings"); Directory.Create("settings");
File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template", File.WriteAllText($"descriptors{Путь.Разд}default.descriptor.template",
ReadResource("launcher_client_win.Resources.default.descriptor.template")); EmbeddedResources.ReadText("Launcher.Client.WPF.Resources.default.descriptor.template"));
CurrentLauncherWindow = new(); CurrentLauncherWindow = new LauncherWindow();
CurrentLauncherWindow.Show(); CurrentLauncherWindow.Show();
} }
public static string ReadResource(string resource_path)
{
using var resourceStreamReader = new System.IO.StreamReader(
Assembly.GetExecutingAssembly().GetManifestResourceStream(resource_path)
?? throw new Exception($"embedded resource <{resource_path}> not found"),
Encoding.UTF8);
return resourceStreamReader.ReadToEnd();
}
public static void LogError(string context, Exception ex) public static void LogError(string context, Exception ex)
{ {

View File

@ -1,7 +1,7 @@
using System.Windows.Controls; using System.Windows.Controls;
using launcher_client_win.GUI; using Launcher.Client.WPF.GUI;
namespace launcher_client_win; namespace Launcher.Client.WPF;
public class Program public class Program
{ {

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -4,7 +4,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<RootNamespace>launcher_client_win</RootNamespace> <RootNamespace>Launcher.Client.WPF</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<DebugType>full</DebugType> <DebugType>full</DebugType>
@ -21,14 +21,14 @@
</ApplicationDefinition> </ApplicationDefinition>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\*" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" /> <Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.dll" />
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" /> <Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Dtsod.dll" />
<Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" /> <Reference Include="..\..\DTLib\bin\Release\net6.0\DTLib.Network.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\*" />
</ItemGroup>
</Project> </Project>

View File

@ -11,26 +11,25 @@ global using System.Threading;
global using System.Linq; global using System.Linq;
using System.Globalization; using System.Globalization;
namespace launcher_server; namespace Launcher.Server;
static class Server static class Server
{ {
static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); static readonly Socket mainSocket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
static DtsodV23 config; static DtsodV23 config;
private static readonly DTLib.Loggers.AsyncLogger Logger = new("logs", "launcher-server"); private static readonly DTLib.Loggers.ConsoleLogger Logger = new("logs", "launcher-server");
static readonly object manifestLocker = new(); static readonly object manifestLocker = new();
static void Main(string[] args) static void Main()
{ {
try try
{ {
Console.Title = "minecraft_launcher_server"; Console.Title = "Launcher.Server";
Console.InputEncoding = Encoding.Unicode; Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode; Console.OutputEncoding = Encoding.Unicode;
Logger.Enable(); PublicLog.LogEvent += Logger.Log;
PublicLog.LogEvent += Logger.LogAsync; PublicLog.LogNoTimeEvent += Logger.Log;
PublicLog.LogNoTimeEvent += Logger.LogAsync;
config = new DtsodV23(File.ReadAllText("launcher-server.dtsod")); config = new DtsodV23(File.ReadAllText("launcher-server.dtsod"));
Logger.Log("b", "local address: <", "c", config["local_ip"], "b", Logger.Log("b", "local address: <", "c", config["local_ip"], "b",
">\npublic address: <", "c", OldNetwork.GetPublicIP(), "b", ">\npublic address: <", "c", OldNetwork.GetPublicIP(), "b",
@ -63,7 +62,7 @@ static class Server
// запускается для каждого юзера в отдельном потоке // запускается для каждого юзера в отдельном потоке
static void UserHandle(Socket handlerSocket) static void UserHandle(Socket handlerSocket)
{ {
Logger.LogAsync("b", "user connecting... "); Logger.Log("b", "user connecting... ");
try try
{ {
// запрос хеша пароля и логина // запрос хеша пароля и логина
@ -74,7 +73,7 @@ static class Server
// запрос от апдейтера // запрос от апдейтера
if (hash == hasher.HashCycled("updater".ToBytes(),64)) if (hash == hasher.HashCycled("updater".ToBytes(),64))
{ {
Logger.LogAsync("b", "user is ", "c", "updater"); Logger.Log("b", "user is ", "c", "updater");
handlerSocket.SendPackage("updater".ToBytes()); handlerSocket.SendPackage("updater".ToBytes());
// обработка запросов // обработка запросов
while (true) while (true)
@ -85,11 +84,11 @@ static class Server
switch (request) switch (request)
{ {
case "requesting launcher update": case "requesting launcher update":
Logger.LogAsync("b", "updater requested client.exe"); Logger.Log("b", "updater requested client.exe");
fsp.UploadFile("share\\launcher.exe"); fsp.UploadFile("share\\launcher.exe");
break; break;
case "register new user": case "register new user":
Logger.LogAsync("b", "new user registration requested"); Logger.Log("b", "new user registration requested");
handlerSocket.SendPackage("ready".ToBytes()); handlerSocket.SendPackage("ready".ToBytes());
string req = StringConverter.MergeToString( string req = StringConverter.MergeToString(
hasher.HashCycled(handlerSocket.GetPackage(), 64).HashToString(), hasher.HashCycled(handlerSocket.GetPackage(), 64).HashToString(),
@ -97,7 +96,7 @@ static class Server
"\";\n\tuuid: \"null\";\n};"); "\";\n\tuuid: \"null\";\n};");
string filepath = $"registration_requests\\{DateTime.Now.ToString(CultureInfo.InvariantCulture).НормализоватьДляПути()}.req"; string filepath = $"registration_requests\\{DateTime.Now.ToString(CultureInfo.InvariantCulture).НормализоватьДляПути()}.req";
File.WriteAllText(filepath, req); File.WriteAllText(filepath, req);
Logger.LogAsync("b", $"text wrote to file <", "c", $"registration_requests\\{filepath}", "b", ">"); Logger.Log("b", $"text wrote to file <", "c", $"registration_requests\\{filepath}", "b", ">");
break; break;
default: default:
throw new Exception("unknown request: " + request); throw new Exception("unknown request: " + request);
@ -109,7 +108,7 @@ static class Server
// запрос от юзера // запрос от юзера
else if (FindUser(hash, out var user)) else if (FindUser(hash, out var user))
{ {
Logger.LogAsync("b", $"user is ", "c", user.name); Logger.Log("b", $"user is ", "c", user.name);
handlerSocket.SendPackage("launcher".ToBytes()); handlerSocket.SendPackage("launcher".ToBytes());
// обработка запросов // обработка запросов
while (true) while (true)
@ -121,7 +120,7 @@ static class Server
{ {
case "requesting file download": case "requesting file download":
var file = handlerSocket.GetPackage().ToString(); var file = handlerSocket.GetPackage().ToString();
Logger.LogAsync("b", $"user ", "c", user.name, "b", " requested file ", "c", file); Logger.Log("b", $"user ", "c", user.name, "b", " requested file ", "c", file);
if (file == "manifest.dtsod") if (file == "manifest.dtsod")
{ {
lock (manifestLocker) fsp.UploadFile("share\\manifest.dtsod"); lock (manifestLocker) fsp.UploadFile("share\\manifest.dtsod");
@ -129,18 +128,18 @@ static class Server
else fsp.UploadFile($"share\\{file}"); else fsp.UploadFile($"share\\{file}");
break; break;
case "requesting uuid": case "requesting uuid":
Logger.LogAsync("b", $"user ", "c", user.name, "b", " requested uuid"); Logger.Log("b", $"user ", "c", user.name, "b", " requested uuid");
handlerSocket.SendPackage(user.uuid.ToBytes()); handlerSocket.SendPackage(user.uuid.ToBytes());
break; break;
case "excess files found": case "excess files found":
Logger.LogAsync("b", $"user ", "c", user.name, "b", " sent excess files list"); Logger.Log("b", $"user ", "c", user.name, "b", " sent excess files list");
fsp.DownloadFile($"excesses\\{user.name}-" + fsp.DownloadFile($"excesses\\{user.name}-" +
$"{DateTime.Now.ToString(CultureInfo.InvariantCulture).НормализоватьДляПути()}.txt"); $"{DateTime.Now.ToString(CultureInfo.InvariantCulture).НормализоватьДляПути()}.txt");
break; break;
case "sending launcher error": case "sending launcher error":
Logger.LogAsync("y", "user ", "c", user.name, "y", "is sending error:"); Logger.Log("y", "user ", "c", user.name, "y", "is sending error:");
string error = handlerSocket.GetPackage().ToString(); string error = handlerSocket.GetPackage().ToString();
Logger.LogAsync("y", error + '\n'); Logger.Log("y", error + '\n');
break; break;
default: default:
throw new Exception("unknown request: " + request); throw new Exception("unknown request: " + request);
@ -152,13 +151,13 @@ static class Server
// неизвестный юзер // неизвестный юзер
else else
{ {
Logger.LogAsync("y", $"user with hash <{hash.HashToString()}> not found"); Logger.Log("y", $"user with hash <{hash.HashToString()}> not found");
handlerSocket.SendPackage("user not found".ToBytes()); handlerSocket.SendPackage("user not found".ToBytes());
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogAsync("y", $"UserStart() error:\n message:\n {ex}"); Logger.Log("y", $"UserStart() error:\n message:\n {ex}");
if (mainSocket.Connected) if (mainSocket.Connected)
{ {
mainSocket.Shutdown(SocketShutdown.Both); mainSocket.Shutdown(SocketShutdown.Both);
@ -169,7 +168,7 @@ static class Server
{ {
if (handlerSocket.Connected) handlerSocket.Shutdown(SocketShutdown.Both); if (handlerSocket.Connected) handlerSocket.Shutdown(SocketShutdown.Both);
handlerSocket.Close(); handlerSocket.Close();
Logger.LogAsync("g", "user disconnected"); Logger.Log("g", "user disconnected");
} }
} }
@ -191,7 +190,7 @@ static class Server
.MergeToString("\",\"") .MergeToString("\",\"")
.Replace($"share\\sync_and_remove\\", "")+ .Replace($"share\\sync_and_remove\\", "")+
"\"];"); "\"];");
}; }
} }
static bool FindUser(byte[] hash, out (string name, string uuid) user) static bool FindUser(byte[] hash, out (string name, string uuid) user)

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<RootNamespace>launcher_server</RootNamespace> <RootNamespace>Launcher.Server</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<DebugType>full</DebugType> <DebugType>full</DebugType>