diff --git a/chatclient/App.config b/chatclient/App.config new file mode 100644 index 0000000..964a4fb --- /dev/null +++ b/chatclient/App.config @@ -0,0 +1,7 @@ + + + +
+ + + \ No newline at end of file diff --git a/chatclient/LoginWindow.xaml b/chatclient/LoginWindow.xaml index 0e55712..df76a3c 100644 --- a/chatclient/LoginWindow.xaml +++ b/chatclient/LoginWindow.xaml @@ -6,7 +6,8 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:chatclient" mc:Ignorable="d" - Title="LoginWindow" Height="600" Width="360"> + Title="LoginWindow" Height="590" Width="360" MinHeight="590" MinWidth="360" MaxHeight="590" MaxWidth="360" + ResizeMode="NoResize"> @@ -14,24 +15,29 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - - - + + + @@ -31,7 +36,7 @@ - + diff --git a/chatclient/MainWindow.xaml.cs b/chatclient/MainWindow.xaml.cs index b29bc62..6ceea4f 100644 --- a/chatclient/MainWindow.xaml.cs +++ b/chatclient/MainWindow.xaml.cs @@ -8,6 +8,13 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Net.Sockets; +using System.Net; +using System.IO; +using System; +using System.Security.Policy; +using log4net; +using log4net.Config; namespace chatclient { @@ -16,14 +23,51 @@ namespace chatclient /// public partial class MainWindow : Window { + static string? receive; + private static readonly ILog log = LogManager.GetLogger(typeof(MainWindow)); + public static Socket Client; public MainWindow() { InitializeComponent(); + log.Info("Hello World!"); + this.Hide(); + Client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + try + { + log.Info("连接服务器 127.0.0.1:5555 "); + Client.Connect("127.0.0.1", 5555); + } + catch (Exception ex) { + log.Error(ex); + } + LoginWindow Login = new LoginWindow(); + Login.Show(); + Thread th = new Thread(Receive); + th.Start(); } - - private void PackIcon_DpiChanged() + static void Receive() { - + byte[] buffer = new byte[1024]; + try + { + while (true) + { + int num = Client.Receive(buffer); + if (num == 0) break; + receive = Encoding.UTF8.GetString(buffer, 0, num); + response(receive); + } + } + catch (Exception ex) { + log.Error(ex); + } + finally + { + Client.Close(); + } + } + static void response(string msg) { + } } } \ No newline at end of file diff --git a/chatclient/chatapi.cs b/chatclient/chatapi.cs new file mode 100644 index 0000000..3f2b168 --- /dev/null +++ b/chatclient/chatapi.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace chatclient +{ + internal class api + { + } +} diff --git a/chatclient/chatclient.csproj b/chatclient/chatclient.csproj index 25fe900..5dd3511 100644 --- a/chatclient/chatclient.csproj +++ b/chatclient/chatclient.csproj @@ -9,9 +9,14 @@ + + + + + diff --git a/chatclient/config/log4net.config b/chatclient/config/log4net.config new file mode 100644 index 0000000..f30cfcc --- /dev/null +++ b/chatclient/config/log4net.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file