├── 使用说明.docx
├── 联系作者.txt
├── 详细设计说明书.doc
├── chatRoomServer
├── chatRoomServer
│ ├── obj
│ │ └── Debug
│ │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ │ │ ├── chatRoomServer.exe
│ │ │ ├── chatRoomServer.pdb
│ │ │ ├── chatRoomServer.Form1.resources
│ │ │ ├── DesignTimeResolveAssemblyReferences.cache
│ │ │ ├── chatRoomServer.csproj.GenerateResource.Cache
│ │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ │ ├── chatRoomServer.Properties.Resources.resources
│ │ │ ├── chatRoomServer.csprojResolveAssemblyReference.cache
│ │ │ └── chatRoomServer.csproj.FileListAbsolute.txt
│ ├── bin
│ │ └── Debug
│ │ │ ├── chatRoomServer.exe
│ │ │ ├── chatRoomServer.pdb
│ │ │ ├── chatRoomServer.vshost.exe
│ │ │ ├── chatRoomServer.exe.config
│ │ │ ├── chatRoomServer.vshost.exe.config
│ │ │ └── chatRoomServer.vshost.exe.manifest
│ ├── App.config
│ ├── Properties
│ │ ├── Settings.settings
│ │ ├── AssemblyInfo.cs
│ │ ├── Settings.Designer.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Program.cs
│ ├── chatRoomServer.csproj
│ ├── Form1.resx
│ ├── Form1.Designer.cs
│ └── Form1.cs
├── chatRoomServer.v12.suo
└── chatRoomServer.sln
├── chatRoomClient
└── chatRoomClient
│ ├── chatRoomClient
│ ├── obj
│ │ └── Debug
│ │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ │ │ ├── chatRoomClient.exe
│ │ │ ├── chatRoomClient.pdb
│ │ │ ├── chatRoomClient.Form1.resources
│ │ │ ├── DesignTimeResolveAssemblyReferences.cache
│ │ │ ├── chatRoomClient.csproj.GenerateResource.Cache
│ │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ │ ├── chatRoomClient.Properties.Resources.resources
│ │ │ ├── chatRoomClient.csprojResolveAssemblyReference.cache
│ │ │ └── chatRoomClient.csproj.FileListAbsolute.txt
│ ├── bin
│ │ └── Debug
│ │ │ ├── chatRoomClient.exe
│ │ │ ├── chatRoomClient.pdb
│ │ │ ├── chatRoomClient.vshost.exe
│ │ │ ├── chatRoomClient.exe.config
│ │ │ ├── chatRoomClient.vshost.exe.config
│ │ │ └── chatRoomClient.vshost.exe.manifest
│ ├── App.config
│ ├── Properties
│ │ ├── Settings.settings
│ │ ├── AssemblyInfo.cs
│ │ ├── Settings.Designer.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Program.cs
│ ├── chatRoomClient.csproj
│ ├── Form1.resx
│ ├── Form1.Designer.cs
│ └── Form1.cs
│ ├── chatRoomClient.v12.suo
│ └── chatRoomClient.sln
├── .gitattributes
└── .gitignore
/使用说明.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/使用说明.docx
--------------------------------------------------------------------------------
/联系作者.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/联系作者.txt
--------------------------------------------------------------------------------
/详细设计说明书.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/详细设计说明书.doc
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer.v12.suo
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient.v12.suo
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.exe
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.pdb
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.exe
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.pdb
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.vshost.exe
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.Form1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.Form1.resources
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.exe
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.pdb
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.exe
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.pdb
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.vshost.exe
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/DesignTimeResolveAssemblyReferences.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/DesignTimeResolveAssemblyReferences.cache
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.Form1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.Form1.resources
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.Properties.Resources.resources
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.csprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.csprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/DesignTimeResolveAssemblyReferences.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/DesignTimeResolveAssemblyReferences.cache
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.Properties.Resources.resources
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.csprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yinyoupoet/chatRoomTest/HEAD/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.csprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.vshost.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.vshost.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/bin/Debug/chatRoomServer.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/bin/Debug/chatRoomClient.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace chatRoomServer
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace chatRoomClient
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.40629.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chatRoomServer", "chatRoomServer\chatRoomServer.csproj", "{452EBD13-32E0-419F-947E-2E0B1FEB86C0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {452EBD13-32E0-419F-947E-2E0B1FEB86C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {452EBD13-32E0-419F-947E-2E0B1FEB86C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {452EBD13-32E0-419F-947E-2E0B1FEB86C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {452EBD13-32E0-419F-947E-2E0B1FEB86C0}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.40629.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chatRoomClient", "chatRoomClient\chatRoomClient.csproj", "{F79D0946-8E4F-4549-8F79-AE483FE6B648}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F79D0946-8E4F-4549-8F79-AE483FE6B648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {F79D0946-8E4F-4549-8F79-AE483FE6B648}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {F79D0946-8E4F-4549-8F79-AE483FE6B648}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {F79D0946-8E4F-4549-8F79-AE483FE6B648}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("chatRoomServer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("chatRoomServer")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("bb82f50c-9eaa-4c2a-be90-089c5a1c00eb")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("chatRoomClient")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("chatRoomClient")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("550b993f-ce58-4657-8a5c-760931eccacb")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace chatRoomServer.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace chatRoomClient.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/obj/Debug/chatRoomClient.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\bin\Debug\chatRoomClient.exe.config
2 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\bin\Debug\chatRoomClient.exe
3 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\bin\Debug\chatRoomClient.pdb
4 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.csprojResolveAssemblyReference.cache
5 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.Form1.resources
6 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.Properties.Resources.resources
7 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.csproj.GenerateResource.Cache
8 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.exe
9 | E:\代码\作业\计网作业\chatRoom\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.pdb
10 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\bin\Debug\chatRoomClient.exe.config
11 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.exe
12 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.pdb
13 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\bin\Debug\chatRoomClient.exe
14 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\bin\Debug\chatRoomClient.pdb
15 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.csprojResolveAssemblyReference.cache
16 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.Form1.resources
17 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.Properties.Resources.resources
18 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomClient\chatRoomClient\chatRoomClient\obj\Debug\chatRoomClient.csproj.GenerateResource.Cache
19 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/obj/Debug/chatRoomServer.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.exe.config
2 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.exe
3 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.pdb
4 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.csprojResolveAssemblyReference.cache
5 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.Form1.resources
6 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.Properties.Resources.resources
7 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.csproj.GenerateResource.Cache
8 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.exe
9 | E:\代码\作业\计网作业\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.pdb
10 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.exe.config
11 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.exe
12 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.pdb
13 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.exe
14 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.pdb
15 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.csprojResolveAssemblyReference.cache
16 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.Form1.resources
17 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.Properties.Resources.resources
18 | E:\代码\作业\计网作业\chatRoom\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.csproj.GenerateResource.Cache
19 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.exe.config
20 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.exe
21 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.pdb
22 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.exe
23 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\bin\Debug\chatRoomServer.pdb
24 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.csprojResolveAssemblyReference.cache
25 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.Form1.resources
26 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.Properties.Resources.resources
27 | E:\代码\作业\计网作业\chatRoom无在线列表备份\chatRoomServer\chatRoomServer\obj\Debug\chatRoomServer.csproj.GenerateResource.Cache
28 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace chatRoomServer.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的、缓存的 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("chatRoomServer.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
56 | /// 方法是使用此强类型资源类。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace chatRoomClient.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的、缓存的 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("chatRoomClient.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
56 | /// 方法是使用此强类型资源类。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/chatRoomClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F79D0946-8E4F-4549-8F79-AE483FE6B648}
8 | WinExe
9 | Properties
10 | chatRoomClient
11 | chatRoomClient
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | Form
50 |
51 |
52 | Form1.cs
53 |
54 |
55 |
56 |
57 | Form1.cs
58 |
59 |
60 | ResXFileCodeGenerator
61 | Resources.Designer.cs
62 | Designer
63 |
64 |
65 | True
66 | Resources.resx
67 |
68 |
69 | SettingsSingleFileGenerator
70 | Settings.Designer.cs
71 |
72 |
73 | True
74 | Settings.settings
75 | True
76 |
77 |
78 |
79 |
80 |
81 |
82 |
89 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/chatRoomServer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {452EBD13-32E0-419F-947E-2E0B1FEB86C0}
8 | WinExe
9 | Properties
10 | chatRoomServer
11 | chatRoomServer
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | Form1.cs
55 |
56 |
57 |
58 |
59 | Form1.cs
60 |
61 |
62 | ResXFileCodeGenerator
63 | Resources.Designer.cs
64 | Designer
65 |
66 |
67 | True
68 | Resources.resx
69 |
70 |
71 | SettingsSingleFileGenerator
72 | Settings.Designer.cs
73 |
74 |
75 | True
76 | Settings.settings
77 | True
78 |
79 |
80 |
81 |
82 |
83 |
84 |
91 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace chatRoomClient
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.lbMsg = new System.Windows.Forms.Label();
32 | this.txtName = new System.Windows.Forms.TextBox();
33 | this.btnConnect = new System.Windows.Forms.Button();
34 | this.txtReceiveMsg = new System.Windows.Forms.TextBox();
35 | this.txtSendMsg = new System.Windows.Forms.TextBox();
36 | this.btnSend = new System.Windows.Forms.Button();
37 | this.labelIP = new System.Windows.Forms.Label();
38 | this.txtIP = new System.Windows.Forms.TextBox();
39 | this.btnBreak = new System.Windows.Forms.Button();
40 | this.SuspendLayout();
41 | //
42 | // lbMsg
43 | //
44 | this.lbMsg.AutoSize = true;
45 | this.lbMsg.Font = new System.Drawing.Font("宋体", 10F);
46 | this.lbMsg.Location = new System.Drawing.Point(8, 27);
47 | this.lbMsg.Name = "lbMsg";
48 | this.lbMsg.Size = new System.Drawing.Size(161, 17);
49 | this.lbMsg.TabIndex = 0;
50 | this.lbMsg.Text = "请设置你的用户名:";
51 | //
52 | // txtName
53 | //
54 | this.txtName.Location = new System.Drawing.Point(175, 19);
55 | this.txtName.Multiline = true;
56 | this.txtName.Name = "txtName";
57 | this.txtName.ShortcutsEnabled = false;
58 | this.txtName.Size = new System.Drawing.Size(200, 30);
59 | this.txtName.TabIndex = 1;
60 | //
61 | // btnConnect
62 | //
63 | this.btnConnect.Location = new System.Drawing.Point(400, 19);
64 | this.btnConnect.Name = "btnConnect";
65 | this.btnConnect.Size = new System.Drawing.Size(100, 30);
66 | this.btnConnect.TabIndex = 2;
67 | this.btnConnect.Text = "连接服务器";
68 | this.btnConnect.UseVisualStyleBackColor = true;
69 | this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
70 | //
71 | // txtReceiveMsg
72 | //
73 | this.txtReceiveMsg.Location = new System.Drawing.Point(42, 77);
74 | this.txtReceiveMsg.Multiline = true;
75 | this.txtReceiveMsg.Name = "txtReceiveMsg";
76 | this.txtReceiveMsg.ReadOnly = true;
77 | this.txtReceiveMsg.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
78 | this.txtReceiveMsg.Size = new System.Drawing.Size(491, 218);
79 | this.txtReceiveMsg.TabIndex = 3;
80 | //
81 | // txtSendMsg
82 | //
83 | this.txtSendMsg.AcceptsReturn = true;
84 | this.txtSendMsg.Location = new System.Drawing.Point(42, 324);
85 | this.txtSendMsg.Multiline = true;
86 | this.txtSendMsg.Name = "txtSendMsg";
87 | this.txtSendMsg.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
88 | this.txtSendMsg.Size = new System.Drawing.Size(491, 93);
89 | this.txtSendMsg.TabIndex = 4;
90 | //
91 | // btnSend
92 | //
93 | this.btnSend.Location = new System.Drawing.Point(60, 449);
94 | this.btnSend.Name = "btnSend";
95 | this.btnSend.Size = new System.Drawing.Size(154, 44);
96 | this.btnSend.TabIndex = 5;
97 | this.btnSend.Text = "发送";
98 | this.btnSend.UseVisualStyleBackColor = true;
99 | this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
100 | //
101 | // labelIP
102 | //
103 | this.labelIP.AutoSize = true;
104 | this.labelIP.Font = new System.Drawing.Font("宋体", 10F);
105 | this.labelIP.Location = new System.Drawing.Point(532, 27);
106 | this.labelIP.Name = "labelIP";
107 | this.labelIP.Size = new System.Drawing.Size(189, 17);
108 | this.labelIP.TabIndex = 6;
109 | this.labelIP.Text = "请输入服务器IP(可选):";
110 | //
111 | // txtIP
112 | //
113 | this.txtIP.Location = new System.Drawing.Point(739, 19);
114 | this.txtIP.Multiline = true;
115 | this.txtIP.Name = "txtIP";
116 | this.txtIP.Size = new System.Drawing.Size(179, 30);
117 | this.txtIP.TabIndex = 7;
118 | //
119 | // btnBreak
120 | //
121 | this.btnBreak.Location = new System.Drawing.Point(321, 449);
122 | this.btnBreak.Name = "btnBreak";
123 | this.btnBreak.Size = new System.Drawing.Size(154, 43);
124 | this.btnBreak.TabIndex = 8;
125 | this.btnBreak.Text = "退出聊天";
126 | this.btnBreak.UseVisualStyleBackColor = true;
127 | this.btnBreak.Click += new System.EventHandler(this.btnBreak_Click);
128 | //
129 | // Form1
130 | //
131 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
132 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
133 | this.ClientSize = new System.Drawing.Size(930, 549);
134 | this.Controls.Add(this.btnBreak);
135 | this.Controls.Add(this.txtIP);
136 | this.Controls.Add(this.labelIP);
137 | this.Controls.Add(this.btnSend);
138 | this.Controls.Add(this.txtSendMsg);
139 | this.Controls.Add(this.txtReceiveMsg);
140 | this.Controls.Add(this.btnConnect);
141 | this.Controls.Add(this.txtName);
142 | this.Controls.Add(this.lbMsg);
143 | this.Name = "Form1";
144 | this.RightToLeft = System.Windows.Forms.RightToLeft.No;
145 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
146 | this.Text = "荆棘鸟聊天系统";
147 | this.Activated += new System.EventHandler(this.Form1_Activated);
148 | this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
149 | this.ResumeLayout(false);
150 | this.PerformLayout();
151 |
152 | }
153 |
154 | #endregion
155 |
156 | private System.Windows.Forms.Label lbMsg;
157 | private System.Windows.Forms.TextBox txtName;
158 | private System.Windows.Forms.Button btnConnect;
159 | private System.Windows.Forms.TextBox txtReceiveMsg;
160 | private System.Windows.Forms.TextBox txtSendMsg;
161 | private System.Windows.Forms.Button btnSend;
162 | private System.Windows.Forms.Label labelIP;
163 | private System.Windows.Forms.TextBox txtIP;
164 | private System.Windows.Forms.Button btnBreak;
165 | }
166 | }
167 |
168 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace chatRoomServer
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.txtMsg = new System.Windows.Forms.TextBox();
32 | this.btnStart = new System.Windows.Forms.Button();
33 | this.btnStop = new System.Windows.Forms.Button();
34 | this.label1 = new System.Windows.Forms.Label();
35 | this.txtIP = new System.Windows.Forms.TextBox();
36 | this.btnResetIp = new System.Windows.Forms.Button();
37 | this.btnRcv = new System.Windows.Forms.Button();
38 | this.btnClear = new System.Windows.Forms.Button();
39 | this.label2 = new System.Windows.Forms.Label();
40 | this.labIPnow = new System.Windows.Forms.Label();
41 | this.SuspendLayout();
42 | //
43 | // txtMsg
44 | //
45 | this.txtMsg.AcceptsReturn = true;
46 | this.txtMsg.Location = new System.Drawing.Point(81, 28);
47 | this.txtMsg.Multiline = true;
48 | this.txtMsg.Name = "txtMsg";
49 | this.txtMsg.ReadOnly = true;
50 | this.txtMsg.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
51 | this.txtMsg.Size = new System.Drawing.Size(424, 239);
52 | this.txtMsg.TabIndex = 0;
53 | //
54 | // btnStart
55 | //
56 | this.btnStart.Location = new System.Drawing.Point(81, 298);
57 | this.btnStart.Name = "btnStart";
58 | this.btnStart.Size = new System.Drawing.Size(81, 42);
59 | this.btnStart.TabIndex = 1;
60 | this.btnStart.Text = "启动";
61 | this.btnStart.UseVisualStyleBackColor = true;
62 | this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
63 | //
64 | // btnStop
65 | //
66 | this.btnStop.Location = new System.Drawing.Point(219, 299);
67 | this.btnStop.Name = "btnStop";
68 | this.btnStop.Size = new System.Drawing.Size(95, 41);
69 | this.btnStop.TabIndex = 2;
70 | this.btnStop.Text = "停止";
71 | this.btnStop.UseVisualStyleBackColor = true;
72 | this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
73 | //
74 | // label1
75 | //
76 | this.label1.AutoSize = true;
77 | this.label1.Location = new System.Drawing.Point(573, 31);
78 | this.label1.Name = "label1";
79 | this.label1.Size = new System.Drawing.Size(151, 15);
80 | this.label1.TabIndex = 3;
81 | this.label1.Text = "重置监听服务器的IP:";
82 | //
83 | // txtIP
84 | //
85 | this.txtIP.Location = new System.Drawing.Point(568, 67);
86 | this.txtIP.Name = "txtIP";
87 | this.txtIP.Size = new System.Drawing.Size(246, 25);
88 | this.txtIP.TabIndex = 4;
89 | //
90 | // btnResetIp
91 | //
92 | this.btnResetIp.Location = new System.Drawing.Point(568, 114);
93 | this.btnResetIp.Name = "btnResetIp";
94 | this.btnResetIp.Size = new System.Drawing.Size(102, 28);
95 | this.btnResetIp.TabIndex = 5;
96 | this.btnResetIp.Text = "重置";
97 | this.btnResetIp.UseVisualStyleBackColor = true;
98 | this.btnResetIp.Click += new System.EventHandler(this.btnResetIp_Click);
99 | //
100 | // btnRcv
101 | //
102 | this.btnRcv.Location = new System.Drawing.Point(714, 114);
103 | this.btnRcv.Name = "btnRcv";
104 | this.btnRcv.Size = new System.Drawing.Size(99, 27);
105 | this.btnRcv.TabIndex = 6;
106 | this.btnRcv.Text = "恢复默认";
107 | this.btnRcv.UseVisualStyleBackColor = true;
108 | this.btnRcv.Click += new System.EventHandler(this.btnRcv_Click);
109 | //
110 | // btnClear
111 | //
112 | this.btnClear.Location = new System.Drawing.Point(368, 299);
113 | this.btnClear.Name = "btnClear";
114 | this.btnClear.Size = new System.Drawing.Size(82, 40);
115 | this.btnClear.TabIndex = 7;
116 | this.btnClear.Text = "清屏";
117 | this.btnClear.UseVisualStyleBackColor = true;
118 | this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
119 | //
120 | // label2
121 | //
122 | this.label2.AutoSize = true;
123 | this.label2.Location = new System.Drawing.Point(554, 246);
124 | this.label2.Name = "label2";
125 | this.label2.Size = new System.Drawing.Size(128, 15);
126 | this.label2.TabIndex = 8;
127 | this.label2.Text = "当前监听的IP为:";
128 | //
129 | // labIPnow
130 | //
131 | this.labIPnow.AutoSize = true;
132 | this.labIPnow.Location = new System.Drawing.Point(688, 246);
133 | this.labIPnow.Name = "labIPnow";
134 | this.labIPnow.Size = new System.Drawing.Size(47, 15);
135 | this.labIPnow.TabIndex = 9;
136 | this.labIPnow.Text = "IPnow";
137 | //
138 | // Form1
139 | //
140 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
141 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
142 | this.ClientSize = new System.Drawing.Size(871, 385);
143 | this.Controls.Add(this.labIPnow);
144 | this.Controls.Add(this.label2);
145 | this.Controls.Add(this.btnClear);
146 | this.Controls.Add(this.btnRcv);
147 | this.Controls.Add(this.btnResetIp);
148 | this.Controls.Add(this.txtIP);
149 | this.Controls.Add(this.label1);
150 | this.Controls.Add(this.btnStop);
151 | this.Controls.Add(this.btnStart);
152 | this.Controls.Add(this.txtMsg);
153 | this.Name = "Form1";
154 | this.Text = "chatRoomServer";
155 | this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
156 | this.Load += new System.EventHandler(this.Form1_Load);
157 | this.ResumeLayout(false);
158 | this.PerformLayout();
159 |
160 | }
161 |
162 | #endregion
163 |
164 | private System.Windows.Forms.TextBox txtMsg;
165 | private System.Windows.Forms.Button btnStart;
166 | private System.Windows.Forms.Button btnStop;
167 | private System.Windows.Forms.Label label1;
168 | private System.Windows.Forms.TextBox txtIP;
169 | private System.Windows.Forms.Button btnResetIp;
170 | private System.Windows.Forms.Button btnRcv;
171 | private System.Windows.Forms.Button btnClear;
172 | private System.Windows.Forms.Label label2;
173 | private System.Windows.Forms.Label labIPnow;
174 | }
175 | }
176 |
177 |
--------------------------------------------------------------------------------
/chatRoomClient/chatRoomClient/chatRoomClient/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Net;
8 | using System.Net.Sockets;
9 | using System.Runtime.InteropServices;
10 | using System.Text;
11 | using System.Threading;
12 | using System.Threading.Tasks;
13 | using System.Windows.Forms;
14 |
15 |
16 | //参考代码:http://www.tuicool.com/articles/RBJFRn
17 | namespace chatRoomClient
18 | {
19 | public partial class Form1 : Form
20 | {
21 | public Form1()
22 | {
23 | InitializeComponent();
24 | ipadr = IPAddress.Loopback;
25 | }
26 |
27 | Socket clientSocket = null;
28 | static Boolean isListen = true;
29 | Thread thDataFromServer;
30 | IPAddress ipadr;
31 |
32 | private void btnSend_Click(object sender, EventArgs e)
33 | {
34 | SendMessage();
35 | }
36 | private void SendMessage()
37 | {
38 | if (String.IsNullOrWhiteSpace(txtSendMsg.Text.Trim()))
39 | {
40 | MessageBox.Show("发送内容不能为空哦~");
41 | return;
42 | }
43 | if (clientSocket != null && clientSocket.Connected)
44 | {
45 | Byte[] bytesSend = Encoding.UTF8.GetBytes(txtSendMsg.Text + "$");
46 | clientSocket.Send(bytesSend);
47 | txtSendMsg.Text = "";
48 | }
49 | else
50 | {
51 | MessageBox.Show("未连接服务器或者服务器已停止,请联系管理员~");
52 | return;
53 | }
54 | }
55 |
56 |
57 | //每一个连接的客户端必须设置一个唯一的用户名,在服务器端是把用户名和套接字保存在Dictionary中
58 | private void btnConnect_Click(object sender, EventArgs e)
59 | {
60 | if (String.IsNullOrWhiteSpace(txtName.Text.Trim()))
61 | {
62 | MessageBox.Show("请设置个用户名哦亲");
63 | return;
64 | }
65 | if (txtName.Text.Length>=17 && txtName.Text.ToString().Trim().Substring(0, 17).Equals("Server has closed"))
66 | {
67 | MessageBox.Show("该用户名中包含敏感词,请更换用户名后重试");
68 | return;
69 | }
70 |
71 | if (clientSocket == null || !clientSocket.Connected)
72 | {
73 | try
74 | {
75 | clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
76 | //参考网址: https://msdn.microsoft.com/zh-cn/library/6aeby4wt.aspx
77 | // Socket.BeginConnect 方法 (String, Int32, AsyncCallback, Object)
78 | //开始一个对远程主机连接的异步请求
79 | /* string host, 远程主机名
80 | * int port, 远程主机的端口
81 | * AsyncCallback requestCallback, 一个 AsyncCallback 委托,它引用连接操作完成时要调用的方法,也是一个异步的操作
82 | * object state 一个用户定义对象,其中包含连接操作的相关信息。 当操作完成时,此对象会被传递给 requestCallback 委托
83 | */
84 | //如果txtIP里面有值,就选择填入的IP作为服务器IP,不填的话就默认是本机的
85 | if (!String.IsNullOrWhiteSpace(txtIP.Text.ToString().Trim()))
86 | {
87 | try
88 | {
89 | ipadr = IPAddress.Parse(txtIP.Text.ToString().Trim());
90 | }
91 | catch
92 | {
93 | MessageBox.Show("请输入正确的IP后重试");
94 | return;
95 | }
96 | }
97 | else
98 | {
99 | ipadr = IPAddress.Loopback;
100 | }
101 | //IPAddress ipadr = IPAddress.Parse("192.168.1.100");
102 | clientSocket.BeginConnect(ipadr, 8080, (args) =>
103 | {
104 | if (args.IsCompleted) //判断该异步操作是否执行完毕
105 | {
106 | Byte[] bytesSend = new Byte[4096];
107 | txtName.BeginInvoke(new Action(() =>
108 | {
109 | bytesSend = Encoding.UTF8.GetBytes(txtName.Text.Trim() + "$"); //用户名,这里是刚刚连接上时需要传过去
110 | if (clientSocket != null && clientSocket.Connected)
111 | {
112 | clientSocket.Send(bytesSend);
113 | txtName.Enabled = false; //设置为不能再改名字了
114 | txtSendMsg.Focus(); //将焦点放在
115 | thDataFromServer = new Thread(DataFromServer);
116 | thDataFromServer.IsBackground = true;
117 | thDataFromServer.Start();
118 | }
119 | else
120 | {
121 | MessageBox.Show("服务器已关闭");
122 | }
123 |
124 | }));
125 | txtIP.BeginInvoke(new Action(() =>
126 | {
127 | if (clientSocket != null && clientSocket.Connected)
128 | {
129 | txtIP.Enabled = false;
130 | }
131 | }));
132 | }
133 | },null);
134 | }
135 | catch (SocketException ex)
136 | {
137 | MessageBox.Show(ex.ToString());
138 | }
139 | }
140 | else
141 | {
142 | MessageBox.Show("你已经连接上服务器了");
143 | }
144 | }
145 |
146 | private void ShowMsg(String msg)
147 | {
148 | txtReceiveMsg.BeginInvoke(new Action(() =>
149 | {
150 | txtReceiveMsg.Text += Environment.NewLine + msg; // 在 Windows 环境中,C# 语言 Environment.NewLine == "\r\n" 结果为 true
151 | //txtReceiveMsg.ScrollToCaret();
152 | }));
153 | }
154 |
155 | //获取服务器端的消息
156 | private void DataFromServer()
157 | {
158 | ShowMsg("Connected to the Chat Server...");
159 | isListen = true;
160 | try
161 | {
162 | while (isListen)
163 | {
164 | Byte[] bytesFrom = new Byte[4096];
165 | Int32 len = clientSocket.Receive(bytesFrom);
166 |
167 | String dataFromClient = Encoding.UTF8.GetString(bytesFrom, 0, len);
168 | if (!String.IsNullOrWhiteSpace(dataFromClient))
169 | {
170 | //如果收到服务器已经关闭的消息,那么就把客户端接口关了,免得出错,并在客户端界面上显示出来
171 | if (dataFromClient.ToString().Length >=17 && dataFromClient.ToString().Substring(0, 17).Equals("Server has closed"))
172 | {
173 | clientSocket.Close();
174 | clientSocket = null;
175 |
176 | txtReceiveMsg.BeginInvoke(new Action(() =>
177 | {
178 | txtReceiveMsg.Text += Environment.NewLine + "服务器已关闭";
179 | }));
180 |
181 | txtName.BeginInvoke(new Action(() =>
182 | {
183 | txtName.Enabled = true;
184 | })); //重连当然可以换用户名啦
185 |
186 | txtIP.BeginInvoke(new Action(() =>
187 | {
188 |
189 | txtIP.Enabled = true;
190 |
191 | }));
192 |
193 | thDataFromServer.Abort(); //这一句必须放在最后,不然这个进程都关了后面的就不会执行了
194 |
195 | return;
196 | }
197 |
198 |
199 | if (dataFromClient.StartsWith("#") && dataFromClient.EndsWith("#"))
200 | {
201 | String userName = dataFromClient.Substring(1, dataFromClient.Length - 2);
202 | this.BeginInvoke(new Action(() =>
203 | {
204 | MessageBox.Show("用户名:[" + userName + "]已经存在,请尝试其他用户名并重试");
205 |
206 | }));
207 | isListen = false;
208 |
209 | txtName.BeginInvoke(new Action(() =>
210 | {
211 | txtName.Enabled = true;
212 | clientSocket.Send(Encoding.UTF8.GetBytes("$"));
213 | clientSocket.Close();
214 | clientSocket = null;
215 | }));
216 | txtIP.BeginInvoke(new Action(() =>
217 | {
218 |
219 | txtIP.Enabled = true;
220 |
221 | }));
222 |
223 | }
224 | else
225 | {
226 | //txtName.Enabled = false; //当用户名唯一时才禁止再次输入用户名
227 | ShowMsg(dataFromClient);
228 | }
229 | }
230 | }
231 | }
232 | catch (SocketException ex)
233 | {
234 | isListen = false;
235 | if (clientSocket != null && clientSocket.Connected)
236 | {
237 | //没有在客户端关闭连接,而是给服务器发送一个消息,在服务器端关闭连接
238 | //这样可以将异常的处理放到服务器。客户端关闭会让客户端和服务器都抛异常
239 | clientSocket.Send(Encoding.UTF8.GetBytes("$"));
240 | MessageBox.Show(ex.ToString());
241 | }
242 | }
243 | }
244 |
245 | private void Form1_Activated(object sender, EventArgs e)
246 | {
247 | txtSendMsg.Focus();
248 | }
249 |
250 | private void Form1_FormClosed(object sender, FormClosedEventArgs e)
251 | {
252 | if (clientSocket != null && clientSocket.Connected)
253 | {
254 | clientSocket.Send(Encoding.UTF8.GetBytes("$"));
255 | }
256 | }
257 |
258 | private void btnBreak_Click(object sender, EventArgs e)
259 | {
260 | if (clientSocket != null && clientSocket.Connected)
261 | {
262 | thDataFromServer.Abort();
263 | clientSocket.Send(Encoding.UTF8.GetBytes("$"));
264 |
265 | clientSocket.Close();
266 | clientSocket = null;
267 |
268 | txtReceiveMsg.BeginInvoke(new Action(() =>
269 | {
270 | txtReceiveMsg.Text += Environment.NewLine + "已断开与服务器的连接";
271 |
272 | }));
273 |
274 | txtName.BeginInvoke(new Action(() =>
275 | {
276 | txtName.Enabled = true;
277 | })); //重连当然可以换用户名啦
278 | txtIP.BeginInvoke(new Action(() =>
279 | {
280 |
281 | txtIP.Enabled = true;
282 |
283 | }));
284 |
285 |
286 | }
287 | }
288 |
289 | }
290 | }
291 |
--------------------------------------------------------------------------------
/chatRoomServer/chatRoomServer/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Net;
8 | using System.Net.Sockets;
9 | using System.Text;
10 | using System.Windows.Threading;
11 | using System.Threading;
12 | using System.Threading.Tasks;
13 | using System.Windows.Forms;
14 | using System.IO;
15 | using System.Security.Cryptography;
16 |
17 |
18 | //参考网址: http://www.tuicool.com/articles/RBJFRn
19 | //参考网址: http://zhangxuefei.site/p/59
20 |
21 | namespace chatRoomServer
22 | {
23 |
24 | public partial class Form1 : Form
25 | {
26 | public Form1()
27 | {
28 | InitializeComponent();
29 | ipadr = IPAddress.Loopback;
30 | }
31 |
32 | //保存多个客户端的通信套接字
33 | public static Dictionary clientList = null;
34 | //申明一个监听套接字
35 | Socket serverSocket = null;
36 | //设置一个监听标记
37 | Boolean isListen = true;
38 | //开启监听的线程
39 | Thread thStartListen;
40 | //默认一个主机监听的IP
41 | IPAddress ipadr;
42 | //将endpoint设置为成员字段
43 | IPEndPoint endPoint;
44 |
45 |
46 | private void btnStart_Click(object sender, EventArgs e)
47 | {
48 | if (serverSocket == null)
49 | {
50 | try
51 | {
52 | isListen = true;
53 | clientList = new Dictionary();
54 |
55 |
56 |
57 | //实例监听套接字
58 |
59 | //参考网址:http://blog.csdn.net/sight_/article/details/8138802
60 | //int socket(int domain, int type, int protocol);
61 | // domain: 协议域,又名协议族。常用的协议族有,AF_INET、AF_INET6、AF_LOCAL(或称AF_UNIX,Unix域socket)、AF_ROUTE等等。
62 | //协议族决定了socket的地址类型,在通信中必须采用对应的地址,如AF_INET决定了要用ipv4地址(32位的)与端口号(16位的)的组合、AF_UNIX决定了要用一个绝对路径名作为地址。
63 | // type: 指定socket类型,。常用的socket类型有,SOCK_STREAM、SOCK_DGRAM、SOCK_RAW、SOCK_PACKET、SOCK_SEQPACKET等等
64 | // protocol: 指定协议。常用的协议有,IPPROTO_TCP、IPPTOTO_UDP、IPPROTO_SCTP、IPPROTO_TIPC等
65 | //并不是上面的type和protocol可以随意组合的,如SOCK_STREAM不可以跟IPPROTO_UDP组合。当protocol为0时,会自动选择type类型对应的默认协议
66 | serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //AddressFamily.InterNetwork代表IPV4地址,不包含IPV6 参考网址:http://bbs.csdn.net/topics/390283656?page=1
67 |
68 | //端点
69 | /* 在IPEndPoint类中有两个很有用的构造函数:
70 | public IPEndPoint(long, int);
71 | public IPEndPoint(IPAddress, int);
72 | 它们的作用就是用指定的地址和端口号初始化IPEndPoint类的新实例。
73 | * 参考网址:http://www.cnblogs.com/Medeor/p/3546359.html
74 | */
75 | //IPAddress ipadr = IPAddress.Parse("192.168.1.100");
76 | //如果txtIP里面有值,就选择填入的IP作为服务器IP,不填的话就默认是本机的
77 |
78 | endPoint = new IPEndPoint(ipadr, 8080); //IPAddress.loopback是本地环回接口,其实是虚拟接口,物理不存在的 参考网址:http://baike.sogou.com/v7893363.htm?fromTitle=loopback
79 |
80 |
81 | //绑定
82 | //把一个地址族的特定地址给socket
83 | //int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
84 | //sockfd: 即socket描述字,它是通过socket()函数创建了,唯一标识一个socket。bind()函数就是将给这个描述字绑定一个名字。
85 | //*addr: 一个const struct sockaddr *指针,指向要绑定给sockfd的协议地址。这个地址结构根据地址创建socket时的地址协议族的不同而不同
86 | //addrlen: 对应的是地址的长度
87 | //通常服务器在启动的时候都会绑定一个众所周知的地址(如ip地址+端口号),用于提供服务,客户就可以通过它来接连服务器;
88 | //而客户端就不用指定,有系统自动分配一个端口号和自身的ip地址组合。
89 | //这就是为什么通常服务器端在listen之前会调用bind(),而客户端就不会调用,而是在connect()时由系统随机生成一个。
90 | //参考网址:http://blog.csdn.net/sight_/article/details/8138802
91 |
92 | //但是这里的bind不是上面的bind,是.NET里面的一个bind,使 Socket 与一个本地终结点相关联。 命名空间:System.Net.Sockets 程序集:System(在 system.dll 中)
93 | //给套接字绑定一个端点,其实差不多用上面的那种bind也能实现
94 | //参考网站: https://msdn.microsoft.com/zh-cn/library/system.net.sockets.socket.bind(VS.80).aspx
95 | //10.127.221.248
96 | try
97 | {
98 | serverSocket.Bind(endPoint);
99 |
100 |
101 |
102 | //设置最大连接数
103 | //如果作为一个服务器,在调用socket()、bind()之后就会调用listen()来监听这个socket,如果客户端这时调用connect()发出连接请求,服务器端就会接收到这个请求。
104 | //int listen(int sockfd, int backlog);
105 | //listen函数的第一个参数即为要监听的socket描述字,第二个参数为相应socket可以排队的最大连接个数。
106 | //socket()函数创建的socket默认是一个主动类型的,listen函数将socket变为被动类型的,等待客户的连接请求。
107 | serverSocket.Listen(100);
108 |
109 |
110 | thStartListen = new Thread(StartListen);
111 | thStartListen.IsBackground = true;
112 | thStartListen.Start();
113 |
114 | //这里有点不一样,原文用的是 txtMsg.Dispatcher.BeginInvoke
115 |
116 | /*Invoke在线程中等待Dispatcher调用指定方法,完成后继续下面的操作。
117 | * BeginInvoke不必等待Dispatcher调用制定方法,直接继续下面的操作。
118 | * 参考网址: https://zhidao.baidu.com/question/1175146013330422099.html?qbl=relate_question_1&word=Dispatcher.BeginInvoke%B5%C4%CF%E0%CD%AC%BA%AF%CA%FD
119 | * 更好的参考网址:http://www.cnblogs.com/lsgsanxiao/p/5523282.html
120 | **/
121 | txtMsg.BeginInvoke(new Action(() =>
122 | {
123 | txtMsg.Text += "服务启动成功...\r\n";
124 | }));
125 | }
126 | catch (Exception eg)
127 | {
128 | MessageBox.Show("输入的IP地址无效,请重新输入!");
129 | txtMsg.BeginInvoke(new Action(() =>
130 | {
131 | txtMsg.Text += "服务启动失败...\r\n";
132 | }));
133 |
134 |
135 | if (serverSocket != null)
136 | {
137 | serverSocket.Close();
138 | thStartListen.Abort(); //将监听进程关掉
139 |
140 | BroadCast.PushMessage("Server has closed", "", false, clientList);
141 | foreach (var socket in clientList.Values)
142 | {
143 | socket.Close();
144 | }
145 | clientList.Clear();
146 |
147 | serverSocket = null;
148 | isListen = false;
149 |
150 | }
151 | }
152 |
153 |
154 | }
155 | catch(SocketException ex)
156 | {
157 | MessageBox.Show(ex.ToString());
158 | }
159 | }
160 |
161 | }
162 |
163 |
164 |
165 | //线程函数,封装一个建立连接的通信套接字
166 | private void StartListen()
167 | {
168 | isListen = true;
169 | //default()只是设置为一个初始值,这里应该为null 参考网址:https://stackoverflow.com/questions/28720717/why-default-in-c-sharp-tcpclient-clientsocket-defaulttcpclient
170 | Socket clientSocket = default(Socket);
171 |
172 | while (isListen)
173 | {
174 | try
175 | {
176 | //参考网址: http://bbs.csdn.net/topics/30100253
177 | // int accept(int sockfd, void *addr, int *addrlen);
178 | //注意这个serverSocket,它是用来监听的套接字,当有用户连接上端口后会返回一个新的套接字也就是这里的clientSocket,sercerSocket还是在那儿继续监听的
179 | //详细参考网址:http://www.360doc.com/content/13/0908/17/13253385_313070996.shtml
180 | //返回值是一个新的套接字描述符,它代表的是和客户端的新的连接,这个socket相当于一个客户端的socket,包含的是客户端的ip和port
181 | //但是它也继承字本地的监听套接字,因此它也有服务器的ip和port信息
182 | if (serverSocket == null) //如果服务停止,即serverSocket为空了,那就直接返回
183 | {
184 | return;
185 | }
186 | clientSocket = serverSocket.Accept(); //这个方法返回一个通信套接字,并用这个套接字进行通信,错误时返回-1并设置全局错误变量
187 | }
188 | catch (SocketException e)
189 | {
190 | File.AppendAllText("E:\\Exception.txt", e.ToString() + "\r\nStartListen\r\n" + DateTime.Now.ToString() + "\r\n");
191 | }
192 |
193 | //TCP是面向字节流的
194 | Byte[] bytesFrom = new Byte[4096];
195 | String dataFromClient = null;
196 |
197 | if (clientSocket != null && clientSocket.Connected)
198 | {
199 | try
200 | {
201 | //Socket.Receive() 参考网址:http://blog.csdn.net/cpcpc/article/details/7245420
202 | //public int Receive( byte[] buffer, int offset, int size, SocketFlags socketFlags )
203 | //buffer 是byte类型的数组,存储收到的数据的位置
204 | //offset 是buffer中存储所接收数据的位置
205 | //size 要接收的字节数
206 | //socketFlags socketFlages值的按位组合
207 |
208 | Int32 len = clientSocket.Receive(bytesFrom); //获取客户端发来的信息,返回的就是收到的字节数,并且把收到的信息都放在bytesForm里面
209 |
210 | if (len > -1)
211 | {
212 | String tmp = Encoding.UTF8.GetString(bytesFrom, 0, len); //将字节流转换成字符串
213 | /*try
214 | {
215 | dataFromClient = EncryptionAndDecryption.TripleDESDecrypting(tmp); //数据加密传输
216 | }
217 | catch (Exception e)
218 | {
219 |
220 | }
221 | catch (Exception e)
222 | {
223 |
224 | }*/
225 | dataFromClient = tmp;
226 | Int32 sublen = dataFromClient.LastIndexOf("$");
227 | if (sublen > -1)
228 | {
229 | dataFromClient = dataFromClient.Substring(0, sublen); //获取用户名
230 |
231 | if (!clientList.ContainsKey(dataFromClient))
232 | {
233 | clientList.Add(dataFromClient, clientSocket); //如果用户名不存在,则添加用户名进去
234 |
235 | //BroadCast是下面自己定义的一个类,是用来将消息对所有用户进行推送的
236 | //PushMessage(String msg, String uName, Boolean flag, Dictionary clientList)
237 | BroadCast.PushMessage(dataFromClient + "Joined", dataFromClient, false, clientList);
238 |
239 | //HandleClient也是一个自己定义的类,用来负责接收客户端发来的消息并转发给所有的客户端
240 | //StartClient(Socket inClientSocket, String clientNo, Dictionary cList)
241 | HandleClient client = new HandleClient(txtMsg);
242 |
243 | client.StartClient(clientSocket, dataFromClient, clientList);
244 |
245 | txtMsg.BeginInvoke(new Action(() =>
246 | {
247 | txtMsg.Text += dataFromClient + "连接上了服务器\r" + DateTime.Now + "\r\n";
248 | }));
249 | }
250 | else
251 | {
252 | //用户名已经存在
253 | clientSocket.Send(Encoding.UTF8.GetBytes("#" + dataFromClient + "#"));
254 | }
255 | }
256 | }
257 | }
258 | catch (Exception ep)
259 | {
260 | File.AppendAllText("E:\\Exception.txt", ep.ToString() + "\r\n\t\t" + DateTime.Now.ToString() + "\r\n");
261 | }
262 |
263 |
264 |
265 | }
266 | }
267 |
268 | }
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 | private void btnStop_Click(object sender, EventArgs e)
278 | {
279 | if (serverSocket != null)
280 | {
281 | serverSocket.Close();
282 | thStartListen.Abort(); //将监听进程关掉
283 |
284 | BroadCast.PushMessage("Server has closed", "", false, clientList);
285 | foreach (var socket in clientList.Values)
286 | {
287 | socket.Close();
288 | }
289 | clientList.Clear();
290 |
291 | serverSocket = null;
292 | isListen = false;
293 | txtMsg.Text += "服务停止,断开所有客户端连接\t"+DateTime.Now.ToString()+"\r\n";
294 | }
295 | }
296 |
297 | private void Form1_Load(object sender, EventArgs e)
298 | {
299 | try
300 | {
301 | clientList = new Dictionary();
302 | serverSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);//实例,监听套接字
303 | //IPAddress ipadr = IPAddress.Parse("192.168.1.100");
304 |
305 | endPoint = new IPEndPoint(ipadr,8080);//端点
306 | serverSocket.Bind(endPoint);//绑定
307 | serverSocket.Listen(100); //设置最大连接数
308 | thStartListen = new Thread(StartListen);
309 | thStartListen.IsBackground = true;
310 | thStartListen.Start();
311 | txtMsg.BeginInvoke(new Action(() =>
312 | {
313 | txtMsg.Text += "服务启动成功...\r\n";
314 | }
315 | ));
316 | labIPnow.BeginInvoke(new Action(() => {
317 | labIPnow.Text = endPoint.Address.ToString();
318 | }));
319 | }
320 | catch (SocketException ep)
321 | {
322 | MessageBox.Show(ep.ToString());
323 | }
324 | }
325 |
326 | private void Form1_FormClosed(object sender, FormClosedEventArgs e)
327 | {
328 | if (serverSocket != null)
329 | {
330 | BroadCast.PushMessage("Server has closed", "", false, clientList);
331 | foreach (var socket in clientList.Values)
332 | {
333 | socket.Close();
334 | }
335 | clientList.Clear();
336 | serverSocket.Close();
337 | serverSocket = null;
338 | isListen = false;
339 | txtMsg.Text += "服务停止\r\n";
340 | }
341 |
342 | }
343 |
344 | //重置监听的IP地址
345 | private void btnResetIp_Click(object sender, EventArgs e)
346 | {
347 |
348 | //如果txtIP里面有值,就选择填入的IP作为服务器IP,不填的话就默认是本机的
349 | if (!String.IsNullOrWhiteSpace(txtIP.Text.ToString().Trim()))
350 | {
351 | try
352 | {
353 | ipadr = IPAddress.Parse(txtIP.Text.ToString().Trim());
354 | btnStop_Click(sender, e);
355 | txtMsg.BeginInvoke(new Action(() =>
356 | {
357 | txtMsg.Text += "服务器重启中,请稍候...\r\n";
358 | }));
359 |
360 | btnStart_Click(sender, e);
361 |
362 |
363 | labIPnow.BeginInvoke(new Action(() =>
364 | {
365 | labIPnow.Text = endPoint.Address.ToString();
366 | }));
367 | }
368 | catch (Exception ep)
369 | {
370 | MessageBox.Show("请输入正确的IP后重试");
371 | }
372 | }
373 | else
374 | {
375 | MessageBox.Show("请输入重置后的IP地址后重试!");
376 | }
377 |
378 |
379 | }
380 |
381 | private void btnRcv_Click(object sender, EventArgs e)
382 | {
383 | if (ipadr == IPAddress.Loopback)
384 | {
385 | MessageBox.Show("当前已经处于默认状态,无需修改");
386 | }
387 | else
388 | {
389 | ipadr = IPAddress.Loopback;
390 | btnStop_Click(sender, e);
391 | txtMsg.BeginInvoke(new Action(() =>
392 | {
393 | txtMsg.Text += "服务器重启中,请稍候...\r\n";
394 | }));
395 | btnStart_Click(sender, e);
396 | labIPnow.BeginInvoke(new Action(() =>
397 | {
398 | labIPnow.Text = endPoint.Address.ToString();
399 | }));
400 | }
401 | }
402 |
403 | private void btnClear_Click(object sender, EventArgs e)
404 | {
405 | txtMsg.BeginInvoke(new Action(() =>
406 | {
407 | txtMsg.Text = "-----------已清屏-----------\r\n";
408 | }));
409 | }
410 |
411 |
412 | }
413 |
414 |
415 | //该类专门负责接收客户端发来的消息,并转发给所有的客户端
416 | public class HandleClient
417 | {
418 | Socket clientSocket;
419 | String clNo;
420 | Dictionary clientList = new Dictionary();
421 | TextBox txtMsg;
422 | public HandleClient() { }
423 | public HandleClient(TextBox tb)
424 | {
425 | txtMsg = tb;
426 | }
427 |
428 |
429 | public void StartClient(Socket inClientSocket, String clientNo, Dictionary cList)
430 | {
431 | clientSocket = inClientSocket;
432 | clNo = clientNo;
433 | clientList = cList;
434 |
435 | Thread th = new Thread(Chat);
436 | th.IsBackground = true;
437 | th.Start();
438 | }
439 |
440 | private void Chat()
441 | {
442 | Byte[] bytesFromClient = new Byte[4096];
443 | String dataFromClient;
444 | String msgTemp = null;
445 | Byte[] bytesSend = new Byte[4096];
446 | Boolean isListen = true;
447 |
448 | while (isListen)
449 | {
450 | try
451 | {
452 | if (clientSocket == null || !clientSocket.Connected)
453 | {
454 | return;
455 | }
456 | if (clientSocket.Available > 0)
457 | {
458 | Int32 len = clientSocket.Receive(bytesFromClient);
459 | if (len > -1)
460 | {
461 | dataFromClient = Encoding.UTF8.GetString(bytesFromClient, 0, len);
462 | if (!String.IsNullOrWhiteSpace(dataFromClient))
463 | {
464 | dataFromClient = dataFromClient.Substring(0, dataFromClient.LastIndexOf("$")); //这里的dataFromClient是消息内容,上面的是用户名
465 | if (!String.IsNullOrWhiteSpace(dataFromClient))
466 | {
467 | BroadCast.PushMessage(dataFromClient, clNo, true, clientList);
468 | msgTemp = clNo + ":" + dataFromClient + "\t\t" + DateTime.Now.ToString();
469 | String newMsg = msgTemp;
470 | File.AppendAllText("E:\\MessageRecords.txt", newMsg + "\r\n", Encoding.UTF8);
471 | }
472 | else
473 | {
474 | isListen = false;
475 | clientList.Remove(clNo);
476 | txtMsg.BeginInvoke(new Action(() =>
477 | {
478 | txtMsg.Text += clNo+ "已断开与服务器连接\r" + DateTime.Now + "\r\n";
479 | }));
480 | BroadCast.PushMessage(clNo + "已下线\r","",false,clientList);
481 | clientSocket.Close();
482 | clientSocket = null;
483 | }
484 | }
485 |
486 | }
487 | }
488 | }
489 | catch (Exception e)
490 | {
491 | isListen = false;
492 | clientList.Remove(clNo);
493 |
494 |
495 | clientSocket.Close();
496 | clientSocket = null;
497 | File.AppendAllText("E:\\Exception.txt",e.ToString()+"\r\nChat\r\n"+DateTime.Now.ToString()+"\r\n");
498 | }
499 | }
500 |
501 | }
502 |
503 | }
504 |
505 | //向所有客户端发送信息
506 | public class BroadCast
507 | {
508 | //flag是用来判断传进来的msg前面是否需要加上uName:,也就是判断是不是系统信息,是系统信息的话就设置flag为false
509 | public static void PushMessage(String msg, String uName, Boolean flag, Dictionary clientList)
510 | {
511 | foreach (var item in clientList)
512 | {
513 | Socket brdcastSocket = (Socket)item.Value;
514 | String msgTemp = null;
515 | Byte[] castBytes = new Byte[4096];
516 | if (flag == true)
517 | {
518 | msgTemp = uName + ":" + msg + "\t\t" + DateTime.Now.ToString();
519 | castBytes = Encoding.UTF8.GetBytes(msgTemp);
520 | }
521 | else
522 | {
523 | msgTemp = msg + "\t\t" + DateTime.Now.ToString();
524 | castBytes = Encoding.UTF8.GetBytes(msgTemp);
525 | }
526 | try
527 | {
528 | brdcastSocket.Send(castBytes);
529 | }
530 | catch (Exception e)
531 | {
532 | brdcastSocket.Close();
533 | brdcastSocket = null;
534 | File.AppendAllText("E:\\Exception.txt",e.ToString()+"\r\nPushMessage\r\n"+DateTime.Now.ToString()+"\r\n");
535 | continue;
536 | }
537 | }
538 | }
539 | }
540 |
541 | }
542 |
--------------------------------------------------------------------------------