├── .gitattributes ├── .gitignore ├── KcpServer ├── KcpClient.net35 │ ├── ConcurrentQueue.cs │ ├── KcpClient.net35.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SpinWait.cs │ ├── kcpwarpper.dll │ └── libikcp.dll ├── KcpClient │ ├── KcpClient.cs │ ├── KcpClient.csproj │ ├── KcpClientEx.cs │ ├── KcpSetting.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── UdpClient.cs │ ├── kcpwarpper.dll │ ├── libikcp.dll │ └── package.nuspec ├── KcpServer.LiteCore │ ├── KcpServer.LiteCore.csproj │ ├── Warpper │ │ ├── IKCPSEG.cs │ │ └── KCP.cs │ └── kcplib.so ├── KcpServer.sln ├── KcpServer │ ├── App.config │ ├── ApplicationBase.cs │ ├── Codec │ │ ├── CodecBase.cs │ │ └── KcpCodec.cs │ ├── ConnectionManager.cs │ ├── IOServer.cs │ ├── KCPClasses │ │ ├── KcpPeerBase.cs │ │ ├── KcpPeerEx.cs │ │ ├── KcpServer.cs │ │ └── KcpServerHandler.cs │ ├── KcpServer.csproj │ ├── KcpSetting.cs │ ├── PeerBase.cs │ ├── PeerContext.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ServerConfig.cs │ ├── UdpServer.cs │ ├── UdpServerHandler.cs │ ├── kcpwarpper.dll │ ├── libikcp.dll │ ├── package.nuspec │ └── packages.config ├── KcpServerLite │ ├── ApplicationBase.cs │ ├── Codec │ │ ├── CodecBase.cs │ │ └── KcpCodec.cs │ ├── ConnectionManager.cs │ ├── KCPClasses │ │ ├── KcpPeerBase.cs │ │ ├── KcpPeerEx.cs │ │ └── KcpServerLite.cs │ ├── KcpServer.Lite.csproj │ ├── PeerBase.cs │ ├── PeerContext.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SendChannel.cs │ ├── ServerConfig.cs │ └── UdpServerLite.cs ├── TestClient │ ├── App.config │ ├── ClientForm1.Designer.cs │ ├── ClientForm1.cs │ ├── ClientForm1.resx │ ├── ClientKcp.Designer.cs │ ├── ClientKcp.cs │ ├── ClientKcp.resx │ ├── ClientMix.Designer.cs │ ├── ClientMix.cs │ ├── ClientMix.resx │ ├── ClientUdp.Designer.cs │ ├── ClientUdp.cs │ ├── ClientUdp.resx │ ├── Images │ │ ├── kcpserver.png │ │ ├── u3dclient.png │ │ └── ubuntu.png │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── TestClient.csproj ├── TestServer.Lite │ ├── App.config │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── TestApplication.cs │ ├── TestPeer.cs │ └── TestServer.Lite.csproj ├── TestServer.LiteCore │ ├── Program.cs │ └── TestServer.LiteCore.csproj ├── TestServer │ ├── App.config │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── ServerForm1.Designer.cs │ ├── ServerForm1.cs │ ├── ServerForm1.resx │ ├── TestApplication.cs │ ├── TestPeer.cs │ └── TestServer.csproj ├── TestU3d │ ├── Assets │ │ ├── Script │ │ │ ├── Test.cs │ │ │ └── TestScript.cs │ │ └── aaaa.unity │ ├── Library │ │ ├── AnnotationManager │ │ ├── AssetImportState │ │ ├── AssetServerCacheV3 │ │ ├── AssetVersioning.db │ │ ├── BuildPlayer.prefs │ │ ├── BuildSettings.asset │ │ ├── CurrentLayout.dwlt │ │ ├── EditorUserBuildSettings.asset │ │ ├── EditorUserSettings.asset │ │ ├── InspectorExpandedItems.asset │ │ ├── LastSceneManagerSetup.txt │ │ ├── LibraryFormatVersion.txt │ │ ├── MonoManager.asset │ │ ├── ProjectSettings.asset │ │ ├── ScriptAssemblies │ │ │ ├── Assembly-CSharp.dll │ │ │ ├── Assembly-CSharp.dll.mdb │ │ │ └── BuiltinAssemblies.stamp │ │ ├── ScriptMapper │ │ ├── ShaderCache │ │ │ ├── 5 │ │ │ │ ├── 50e978ae2b8aeb852d38754114b5918a.bin │ │ │ │ └── 56f3b856f7d96adb19b4a9a6f38c4a13.bin │ │ │ ├── 6 │ │ │ │ └── 67139f55793d4e2e36244363e4dc999d.bin │ │ │ ├── 7 │ │ │ │ └── 79d4d60e848d5db61d698b53d65a5676.bin │ │ │ ├── 8 │ │ │ │ ├── 8ad788dff8db13e50c06e32bb9c2c452.bin │ │ │ │ └── 8e33aedd948632d631fb31f32ce19593.bin │ │ │ ├── 9 │ │ │ │ └── 9ea2134cde481652e76ca73f8fea90b6.bin │ │ │ ├── b │ │ │ │ └── bfbe139b7fe6f9dcc6ddb52a33a7dd8f.bin │ │ │ ├── c │ │ │ │ └── c67b3c7d3c93aade82053b2950c85cde.bin │ │ │ └── f │ │ │ │ └── f25cfe62e5edcc3e62471f8f427277f8.bin │ │ ├── UnityAssemblies │ │ │ ├── UnityEditor.dll │ │ │ ├── UnityEditor.xml │ │ │ ├── UnityEngine.Networking.dll │ │ │ ├── UnityEngine.Networking.xml │ │ │ ├── UnityEngine.UI.dll │ │ │ ├── UnityEngine.UI.xml │ │ │ ├── UnityEngine.dll │ │ │ ├── UnityEngine.xml │ │ │ └── version.txt │ │ ├── assetDatabase3 │ │ ├── expandedItems │ │ └── metadata │ │ │ ├── 34 │ │ │ ├── 34a1b6c94ffd2ed4cb00d9fd8a4e7bf0 │ │ │ └── 34a1b6c94ffd2ed4cb00d9fd8a4e7bf0.info │ │ │ ├── 49 │ │ │ ├── 49b0a1b03cd120841b34607dc7762975 │ │ │ └── 49b0a1b03cd120841b34607dc7762975.info │ │ │ ├── 54 │ │ │ ├── 545c21c93e5b59b40bc3c9687584ba8e │ │ │ └── 545c21c93e5b59b40bc3c9687584ba8e.info │ │ │ ├── 73 │ │ │ ├── 739bbd9f364b4268874f9fd86ab3beef │ │ │ └── 739bbd9f364b4268874f9fd86ab3beef.info │ │ │ ├── 74 │ │ │ ├── 744874c484c2e1344a374081bafdca93 │ │ │ └── 744874c484c2e1344a374081bafdca93.info │ │ │ ├── 79 │ │ │ ├── 7909d14fbd7075848a75e5cc1d04d145 │ │ │ └── 7909d14fbd7075848a75e5cc1d04d145.info │ │ │ ├── 80 │ │ │ ├── 80a3616ca19596e4da0f10f14d241e9f │ │ │ └── 80a3616ca19596e4da0f10f14d241e9f.info │ │ │ ├── 85 │ │ │ ├── 852e56802eb941638acbb491814497b0 │ │ │ └── 852e56802eb941638acbb491814497b0.info │ │ │ ├── 86 │ │ │ ├── 8662cdb7d9c58da4e871e9cd7253993e │ │ │ └── 8662cdb7d9c58da4e871e9cd7253993e.info │ │ │ ├── 87 │ │ │ ├── 870353891bb340e2b2a9c8707e7419ba │ │ │ └── 870353891bb340e2b2a9c8707e7419ba.info │ │ │ ├── 89 │ │ │ ├── 89b17335b6b86fa46ba3cec8ab68e905 │ │ │ └── 89b17335b6b86fa46ba3cec8ab68e905.info │ │ │ ├── 95 │ │ │ ├── 951d0179d2661f4498773ccaa0ff9605 │ │ │ └── 951d0179d2661f4498773ccaa0ff9605.info │ │ │ ├── 97 │ │ │ ├── 97decbdab0634cdd991f8d23ddf0dead │ │ │ └── 97decbdab0634cdd991f8d23ddf0dead.info │ │ │ ├── 00 │ │ │ ├── 00000000000000001000000000000000 │ │ │ ├── 00000000000000001000000000000000.info │ │ │ ├── 00000000000000002000000000000000 │ │ │ ├── 00000000000000002000000000000000.info │ │ │ ├── 00000000000000003000000000000000 │ │ │ ├── 00000000000000003000000000000000.info │ │ │ ├── 00000000000000004000000000000000 │ │ │ ├── 00000000000000004000000000000000.info │ │ │ ├── 00000000000000004100000000000000 │ │ │ ├── 00000000000000004100000000000000.info │ │ │ ├── 00000000000000005000000000000000 │ │ │ ├── 00000000000000005000000000000000.info │ │ │ ├── 00000000000000005100000000000000 │ │ │ ├── 00000000000000005100000000000000.info │ │ │ ├── 00000000000000006000000000000000 │ │ │ ├── 00000000000000006000000000000000.info │ │ │ ├── 00000000000000006100000000000000 │ │ │ ├── 00000000000000006100000000000000.info │ │ │ ├── 00000000000000007000000000000000 │ │ │ ├── 00000000000000007000000000000000.info │ │ │ ├── 00000000000000007100000000000000 │ │ │ ├── 00000000000000007100000000000000.info │ │ │ ├── 00000000000000008000000000000000 │ │ │ ├── 00000000000000008000000000000000.info │ │ │ ├── 00000000000000008100000000000000 │ │ │ ├── 00000000000000008100000000000000.info │ │ │ ├── 00000000000000009000000000000000 │ │ │ ├── 00000000000000009000000000000000.info │ │ │ ├── 0000000000000000a000000000000000 │ │ │ ├── 0000000000000000a000000000000000.info │ │ │ ├── 0000000000000000a100000000000000 │ │ │ ├── 0000000000000000a100000000000000.info │ │ │ ├── 0000000000000000b000000000000000 │ │ │ ├── 0000000000000000b000000000000000.info │ │ │ ├── 0000000000000000c000000000000000 │ │ │ └── 0000000000000000c000000000000000.info │ │ │ ├── 0d │ │ │ ├── 0d9af4055650a4a4aabd94898e22462a │ │ │ └── 0d9af4055650a4a4aabd94898e22462a.info │ │ │ ├── 2d │ │ │ ├── 2dbc27900c48e94458b6cc3f2a9ece09 │ │ │ └── 2dbc27900c48e94458b6cc3f2a9ece09.info │ │ │ ├── 3c │ │ │ ├── 3c0ad459c1534645b5d603b7cc258f97 │ │ │ └── 3c0ad459c1534645b5d603b7cc258f97.info │ │ │ ├── 4a │ │ │ ├── 4a29928001fcb444e8f830b166827fa2 │ │ │ └── 4a29928001fcb444e8f830b166827fa2.info │ │ │ ├── 5f │ │ │ ├── 5f32cd94baa94578a686d4b9d6b660f7 │ │ │ └── 5f32cd94baa94578a686d4b9d6b660f7.info │ │ │ ├── 7c │ │ │ ├── 7cbab2be89b54486bbd23a6fe637d30e │ │ │ └── 7cbab2be89b54486bbd23a6fe637d30e.info │ │ │ ├── 8e │ │ │ ├── 8e0cd8ed44d4412cbe0642067abc9e44 │ │ │ └── 8e0cd8ed44d4412cbe0642067abc9e44.info │ │ │ ├── a7 │ │ │ ├── a72c9d1faa3616e4da86af09280a5e13 │ │ │ └── a72c9d1faa3616e4da86af09280a5e13.info │ │ │ ├── ad │ │ │ ├── adebbd281f1a4ef3a30be7f21937e02f │ │ │ └── adebbd281f1a4ef3a30be7f21937e02f.info │ │ │ ├── bc │ │ │ ├── bc0915f93bc20bb4f90dead66b755481 │ │ │ └── bc0915f93bc20bb4f90dead66b755481.info │ │ │ ├── d7 │ │ │ ├── d72e8ef70b3ab1e4b829e212338969d6 │ │ │ └── d72e8ef70b3ab1e4b829e212338969d6.info │ │ │ ├── ee │ │ │ ├── eecd871b25c187b4fa1d82d8b2376c56 │ │ │ └── eecd871b25c187b4fa1d82d8b2376c56.info │ │ │ ├── f3 │ │ │ ├── f38eedb01e55a424eb25b101fc67ef5b │ │ │ └── f38eedb01e55a424eb25b101fc67ef5b.info │ │ │ └── f5 │ │ │ ├── f5f67c52d1564df4a8936ccd202a3bd8 │ │ │ └── f5f67c52d1564df4a8936ccd202a3bd8.info │ ├── ProjectSettings │ │ ├── AudioManager.asset │ │ ├── ClusterInputManager.asset │ │ ├── DynamicsManager.asset │ │ ├── EditorBuildSettings.asset │ │ ├── EditorSettings.asset │ │ ├── GraphicsSettings.asset │ │ ├── InputManager.asset │ │ ├── NavMeshAreas.asset │ │ ├── NetworkManager.asset │ │ ├── Physics2DSettings.asset │ │ ├── ProjectSettings.asset │ │ ├── ProjectVersion.txt │ │ ├── QualitySettings.asset │ │ ├── TagManager.asset │ │ ├── TimeManager.asset │ │ ├── UnityAdsSettings.asset │ │ └── UnityConnectSettings.asset │ ├── Temp │ │ └── __Backupscenes │ │ │ └── 0.backup │ ├── Test.sln │ ├── TestU3d.csproj │ └── TestU3d.sln └── Utilities │ ├── Fiber.cs │ ├── FiberPool.cs │ ├── IFiber.cs │ ├── MakeTestBuff.cs │ ├── PPack.cs │ ├── ServerPackBuilder.cs │ ├── ServerPackBuilderEx.cs │ ├── Utilities.projitems │ └── Utilities.shproj ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain -------------------------------------------------------------------------------- /KcpServer/KcpClient.net35/ConcurrentQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace System.Collections.Concurrent 5 | { 6 | public class ConcurrentQueue 7 | { 8 | Queue innerQueue = null; 9 | public ConcurrentQueue() 10 | { 11 | innerQueue = new Queue(); 12 | } 13 | public bool TryDequeue(out T item) 14 | { 15 | lock (innerQueue) 16 | { 17 | if (innerQueue.Count > 0) 18 | { 19 | item = innerQueue.Dequeue(); 20 | return true; 21 | } 22 | else 23 | { 24 | item = default(T); 25 | return false; 26 | } 27 | } 28 | } 29 | 30 | public void Enqueue(T item) 31 | { 32 | lock (innerQueue) 33 | { 34 | innerQueue.Enqueue(item); 35 | } 36 | } 37 | public int Count 38 | { 39 | get 40 | { 41 | 42 | lock (innerQueue) 43 | { 44 | return innerQueue.Count; 45 | }; 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /KcpServer/KcpClient.net35/KcpClient.net35.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B766FBA2-B84E-4E12-95A2-7C9D7CDA60D5} 8 | Library 9 | Properties 10 | KcpClient 11 | KcpClient 12 | v3.5 13 | 512 14 | Client 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\x64\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | x64 25 | true 26 | 27 | 28 | pdbonly 29 | true 30 | bin\x64\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | x64 35 | true 36 | 37 | 38 | 39 | False 40 | ..\KcpClient\kcpwarpper.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | KcpClient.cs 52 | 53 | 54 | KcpClientEx.cs 55 | 56 | 57 | KcpSetting.cs 58 | 59 | 60 | UdpClient.cs 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Always 69 | 70 | 71 | Always 72 | 73 | 74 | Always 75 | 76 | 77 | Always 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /KcpServer/KcpClient.net35/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("KcpClient.net35")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("KcpClient.net35")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b766fba2-b84e-4e12-95a2-7c9d7cda60d5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /KcpServer/KcpClient.net35/SpinWait.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | 7 | namespace System.Threading 8 | { 9 | internal class SpinWait 10 | { 11 | public void SpinOnce() 12 | { 13 | if (Environment.OSVersion.Platform == PlatformID.Win32NT) 14 | { 15 | 16 | } 17 | Thread.Sleep(0); 18 | } 19 | ISpinOnce spin = null; 20 | public SpinWait() 21 | { 22 | switch (Environment.OSVersion.Platform) 23 | { 24 | case PlatformID.Win32NT: 25 | this.spin = new WinSpin(); 26 | break; 27 | case PlatformID.Unix: 28 | this.spin = new LinuxSpin(); 29 | break; 30 | case PlatformID.MacOSX: 31 | throw new NotImplementedException($"not ready for {Environment.OSVersion.Platform}"); 32 | break; 33 | default: 34 | throw new NotImplementedException($"not support for {Environment.OSVersion.Platform}"); 35 | break; 36 | } 37 | } 38 | 39 | interface ISpinOnce 40 | { 41 | void SpinOnce(); 42 | } 43 | class WinSpin : ISpinOnce 44 | { 45 | public void SpinOnce() 46 | { 47 | Thread.Sleep(0); 48 | } 49 | } 50 | class LinuxSpin : ISpinOnce 51 | { 52 | public void SpinOnce() 53 | { 54 | throw new NotImplementedException(); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /KcpServer/KcpClient.net35/kcpwarpper.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpClient.net35/kcpwarpper.dll -------------------------------------------------------------------------------- /KcpServer/KcpClient.net35/libikcp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpClient.net35/libikcp.dll -------------------------------------------------------------------------------- /KcpServer/KcpClient/KcpClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A2A74321-0F1A-4FDD-8EA3-21C8F32AD730} 8 | Library 9 | Properties 10 | KcpClient 11 | KcpClient 12 | v4.6.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\x64\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | x64 24 | true 25 | 26 | 27 | pdbonly 28 | true 29 | bin\x64\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | x64 35 | 36 | 37 | 38 | False 39 | .\kcpwarpper.dll 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Always 63 | 64 | 65 | Always 66 | 67 | 68 | Always 69 | 70 | 71 | Always 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /KcpServer/KcpClient/KcpClientEx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using kcpwarpper; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace KcpClient 7 | { 8 | public class KcpClientEx : KcpClient 9 | { 10 | public KcpClientEx(byte[] arr, int sid, byte[] appData) : base(arr, sid, appData) 11 | { 12 | } 13 | protected override void ProcessIncomingData(byte[] data, int start, int len) 14 | { 15 | //if (data.Length > 0) 16 | if (len > 0) 17 | { 18 | var type = (Utilities.PackType)data[start]; 19 | switch (type) 20 | { 21 | case Utilities.PackType.Udp: 22 | var realdata = new byte[len - 1];//todo , try to reuse 23 | Array.Copy(data, start + 1, realdata, 0, realdata.Length); 24 | if (Incoming != null) 25 | { 26 | Incoming.Enqueue(realdata); 27 | } 28 | break; 29 | case Utilities.PackType.Kcp: 30 | base.ProcessIncomingData(data, start + 1, len - 1); 31 | break; 32 | default: 33 | //unknown packtype, drop it 34 | debug($"unknown packtype, drop it. typeid = {type}"); 35 | break; 36 | } 37 | 38 | } 39 | 40 | } 41 | /// 42 | /// default is reliable 43 | /// 44 | /// 45 | public override void SendOperationRequest(byte[] buff) 46 | { 47 | SendOperationRequest(buff, false); 48 | } 49 | public virtual void SendOperationRequest(byte[] buff, bool unreliable) 50 | { 51 | if (!Connected) 52 | { 53 | throw new InvalidOperationException("not connected"); 54 | } 55 | byte[] newbuff = PackReliable(buff, unreliable); 56 | ProcessOutgoingData(newbuff, 0, newbuff.Length); 57 | } 58 | 59 | private static byte[] PackReliable(byte[] buff, bool unreliable) 60 | { 61 | var newbuff = new byte[buff.Length + 1]; 62 | byte type; 63 | if (unreliable) 64 | { 65 | type = (byte)Utilities.PackType.Udp; 66 | } 67 | else 68 | { 69 | type = (byte)Utilities.PackType.Kcp; 70 | } 71 | newbuff[0] = type; 72 | Array.Copy(buff, 0, newbuff, 1, buff.Length); 73 | return newbuff; 74 | } 75 | 76 | protected override void ProcessOutgoingData(byte[] buff, int start, int len) 77 | { 78 | var type = (Utilities.PackType)buff[start]; 79 | switch (type) 80 | { 81 | case Utilities.PackType.Udp: 82 | if (Outgoing != null) 83 | { 84 | if (start == 0) 85 | { 86 | Outgoing.Enqueue(buff); 87 | } 88 | else 89 | { 90 | var buf = new byte[len]; 91 | Array.Copy(buff, start, buf, 0, len); 92 | Outgoing.Enqueue(buf); 93 | } 94 | } 95 | break; 96 | case Utilities.PackType.Kcp: 97 | base.ProcessOutgoingData(buff, start + 1, len - 1); 98 | break; 99 | default: 100 | break; 101 | } 102 | } 103 | 104 | protected override unsafe int udp_output(byte* buf, int len, IKCPCB* kcp, void* user) 105 | { 106 | byte[] buff = new byte[len + 1]; 107 | Marshal.Copy(new IntPtr(buf), buff, 1, len); 108 | #if PRINTPACK 109 | printpack($"kcp_output:{buff.Length}:{string.Join(",",buff)}"); 110 | #endif 111 | buff[0] = (byte)Utilities.PackType.Kcp; 112 | if (Outgoing != null) 113 | { 114 | Outgoing.Enqueue(buff); 115 | } 116 | return 0; 117 | } 118 | public override int MaxKcpPackSize => Utilities.PackSettings.MAX_DATA_LEN - 1; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /KcpServer/KcpClient/KcpSetting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace KcpClient 7 | { 8 | public class KcpSetting 9 | { 10 | public int RecWindowSize { get; set; } = 128; 11 | public int SndWindowSize { get; set; } = 128; 12 | /// 13 | /// 是否启用 nodelay模式,0不启用;1启用。 14 | /// 15 | public int NoDelay { get; set; } = 1; 16 | 17 | /// 18 | /// 协议内部工作的 interval,单位毫秒,比如 10ms或者 20ms 19 | /// 20 | public int NoDelayInterval { get; set; } = 10; 21 | /// 22 | /// 重发跨越包数量,2表示两次ack跨越直接重新传 23 | /// 24 | public int NoDelayResend { get; set; } = 2; 25 | /// 26 | /// 是否启用流量控制 27 | /// 28 | public int NoDelayNC { get; set; } = 1; 29 | //public int NoDelay { get; set; } = 1; 30 | /// 31 | /// 检测丢包的时间间隔,RTO时都有最小 RTO的限制,即便计算出来RTO为40ms,由于默认的 RTO是100ms,协议只有在100ms后才能检测到丢包,快速模式下为30ms,可以手动更改该值 32 | /// 33 | public int RTO { get; set; } = 100; 34 | 35 | 36 | 37 | private KcpSetting() 38 | { 39 | 40 | } 41 | 42 | static KcpSetting _setting = new KcpSetting(); 43 | 44 | public static KcpSetting Default 45 | { 46 | get 47 | { 48 | return _setting; 49 | } 50 | } 51 | 52 | public int MTU { get; set; } = Utilities.PackSettings.MAX_DATA_LEN; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /KcpServer/KcpClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpClient/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /KcpServer/KcpClient/kcpwarpper.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpClient/kcpwarpper.dll -------------------------------------------------------------------------------- /KcpServer/KcpClient/libikcp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpClient/libikcp.dll -------------------------------------------------------------------------------- /KcpServer/KcpClient/package.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $id$ 6 | 7 | 0.1.1.7 8 | 9 | 10 | 11 | $author$ 12 | $author$ 13 | 18 | false 19 | 20 | $description$ 21 | 22 | do&#x0020;not&#x0020;use&#x0020;it&#x0020;before&#x0020;1.0 23 | $copyright$ 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /KcpServer/KcpServer.LiteCore/KcpServer.LiteCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | 6 | 7 | 8 | true 9 | x64 10 | bin\x64\Debug\netcoreapp2.0\ 11 | 12 | 13 | 14 | true 15 | x64 16 | bin\x64\Release\netcoreapp2.0\ 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | kcpwarpper.dll 38 | 39 | 40 | 41 | 42 | 43 | PreserveNewest 44 | 45 | 46 | PreserveNewest 47 | 48 | 49 | PreserveNewest 50 | 51 | 52 | PreserveNewest 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Always 64 | 65 | 66 | Always 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /KcpServer/KcpServer.LiteCore/Warpper/IKCPSEG.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace kcpwarpper 9 | { 10 | public unsafe struct IQUEUEHEAD 11 | { 12 | public IQUEUEHEAD* next; 13 | public IQUEUEHEAD* prev; 14 | }; 15 | //===================================================================== 16 | // SEGMENT 17 | //===================================================================== 18 | public unsafe struct IKCPSEG 19 | { 20 | public IQUEUEHEAD node; 21 | public uint conv; 22 | public uint cmd; 23 | public uint frg; 24 | public uint wnd; 25 | public uint ts; 26 | public uint sn; 27 | public uint una; 28 | public uint len; 29 | public uint resendts; 30 | public uint rto; 31 | public uint fastack; 32 | public uint xmit; 33 | //char data[1]; 34 | fixed byte data[1]; 35 | }; 36 | 37 | 38 | //--------------------------------------------------------------------- 39 | // IKCPCB 40 | //--------------------------------------------------------------------- 41 | public unsafe struct IKCPCB 42 | { 43 | public uint conv, mtu, mss, state; 44 | public uint snd_una, snd_nxt, rcv_nxt; 45 | public uint ts_recent, ts_lastack, ssthresh; 46 | //IINT32 rx_rttval, rx_srtt, rx_rto, rx_minrto; 47 | public int rx_rttval, rx_srtt, rx_rto, rx_minrto; 48 | public uint snd_wnd, rcv_wnd, rmt_wnd, cwnd, probe; 49 | public uint current, interval, ts_flush, xmit; 50 | public uint nrcv_buf, nsnd_buf; 51 | public uint nrcv_que, nsnd_que; 52 | public uint nodelay, updated; 53 | public uint ts_probe, probe_wait; 54 | public uint dead_link, incr; 55 | public IQUEUEHEAD snd_queue; 56 | public IQUEUEHEAD rcv_queue; 57 | public IQUEUEHEAD snd_buf; 58 | public IQUEUEHEAD rcv_buf; 59 | public uint* acklist; 60 | public uint ackcount; 61 | public uint ackblock; 62 | public void* user; 63 | public char* buffer; 64 | public int fastresend; 65 | public int nocwnd, stream; 66 | public int logmask; 67 | //int (* output) (const char* buf, int len, struct IKCPCB *kcp, void* user); 68 | //void (* writelog) (const char* log, struct IKCPCB *kcp, void* user); 69 | /// 70 | /// if func from dll 71 | /// IntPtr dll = LoadLibrary("xxx.dll");   72 | /// IntPtr func = GetProcAddress(dll, "funcname"); 73 | /// d_output output = (d_output)Marshal.GetDelegateForFunctionPointer(func, typeof(d_output));   74 | /// else 75 | /// IKCPCB ikcpcb; 76 | /// d_writelog act = (a, b, c) => { }; 77 | /// ikcpcb.writelog = Marshal.GetFunctionPointerForDelegate(act); 78 | /// output = Marshal.GetFunctionPointerForDelegate(new k.d_output(udp_output)); 79 | /// 80 | public IntPtr output; 81 | public IntPtr writelog; 82 | }; 83 | [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] 84 | public unsafe delegate int d_output(byte *buf, int len, IKCPCB* kcp, void* user); 85 | [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] 86 | public unsafe delegate void d_writelog(byte* log, IKCPCB* kcp, void* user); 87 | 88 | #region interface 89 | 90 | #endregion 91 | 92 | 93 | 94 | unsafe class pp 95 | { 96 | unsafe void p() 97 | { 98 | IKCPCB ikcpcb; 99 | d_writelog act = (a, b, c) => { }; 100 | ikcpcb.writelog = Marshal.GetFunctionPointerForDelegate(act); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /KcpServer/KcpServer.LiteCore/kcplib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpServer.LiteCore/kcplib.so -------------------------------------------------------------------------------- /KcpServer/KcpServer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/ApplicationBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using Utilities; 10 | 11 | namespace KcpServer 12 | { 13 | public abstract class ApplicationBase 14 | { 15 | ConnectionManager ConnMan; 16 | private EndPoint _localEndPoint; 17 | 18 | internal void SetConnMan(ConnectionManager cm) 19 | { 20 | ConnMan = cm; 21 | } 22 | 23 | public bool ApplicationRunning { get; internal set; } = true; 24 | public EndPoint LocalEndPoint { get => _localEndPoint; /*set => localEndPoint = value;*/ } 25 | 26 | public virtual bool PreCreatePeer(PeerContext peerContext) 27 | { 28 | return true; 29 | } 30 | /// 31 | /// if eject return null. 32 | /// 33 | /// 34 | public abstract PeerBase CreatePeer(PeerContext peerContext); 35 | 36 | public abstract void Setup(); 37 | 38 | public abstract void TearDown(); 39 | 40 | internal void Close() 41 | { 42 | if (ApplicationRunning) 43 | { 44 | TearDown(); 45 | ApplicationRunning = false; 46 | } 47 | } 48 | 49 | internal void SetLocalEndPoint(EndPoint localEndPoint) 50 | { 51 | this._localEndPoint = localEndPoint; 52 | } 53 | 54 | 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/Codec/CodecBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace KcpServer.Codec 8 | { 9 | public class CodecBase 10 | { 11 | public virtual void Close() 12 | { 13 | #if DEBUG 14 | Console.WriteLine($"{nameof(CodecBase)} {nameof(Close)}"); 15 | #endif 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/Codec/KcpCodec.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using static kcpwarpper.KCP; 8 | namespace KcpServer.Codec 9 | { 10 | public unsafe class KcpCodec : CodecBase 11 | { 12 | private PeerContext x; 13 | public KcpCodec(PeerContext x) 14 | { 15 | this.x = x; 16 | CreateKcp(x); 17 | 18 | } 19 | public virtual int MaxKcpPackSize { get => Utilities.PackSettings.MAX_DATA_LEN; } 20 | public void CreateKcp(PeerContext x) 21 | { 22 | if (x.EncoderData == null) 23 | { 24 | var errno = ikcp_create((uint)x.SessionId, (void*)0); 25 | if ((int)errno != -1) 26 | { 27 | x.EncoderData = errno; 28 | #if PRINTPACK 29 | Console.WriteLine($"create kcp {(int)x.EncoderData}"); 30 | #endif 31 | var kcp = x.EncoderData; 32 | /*该调用将会设置协议的最大发送窗口和最大接收窗口大小,默认为32. 这个可以理解为 TCP的 SND_BUF 和 RCV_BUF,只不过单位不一样 SND/RCV_BUF 单位是字节,这个单位是包。*/ 33 | 34 | //ikcp_wndsize(kcp, 128, 128); 35 | //ikcp_wndsize(kcp, KcpSetting.Default.SndWindowSize, KcpSetting.Default.RecWindowSize); 36 | ikcp_wndsize(kcp, KcpSetting.Default.SndWindowSize, KcpSetting.Default.RecWindowSize); 37 | 38 | /* 39 | nodelay :是否启用 nodelay模式,0不启用;1启用。 40 | interval :协议内部工作的 interval,单位毫秒,比如 10ms或者 20ms 41 | resend :快速重传模式,默认0关闭,可以设置2(2次ACK跨越将会直接重传) 42 | nc :是否关闭流控,默认是0代表不关闭,1代表关闭。 43 | 普通模式:`ikcp_nodelay(kcp, 0, 40, 0, 0); 44 | 极速模式: ikcp_nodelay(kcp, 1, 10, 2, 1); 45 | */ 46 | //ikcp_nodelay(kcp, 1, 10, 2, 1); 47 | ikcp_nodelay(kcp, KcpSetting.Default.NoDelay, KcpSetting.Default.NoDelayInterval, KcpSetting.Default.NoDelayResend, KcpSetting.Default.NoDelayNC); 48 | int mtu = Math.Min(MaxKcpPackSize, KcpSetting.Default.MTU); 49 | /*最大传输单元:纯算法协议并不负责探测 MTU,默认 mtu是1400字节,可以使用ikcp_setmtu来设置该值。该值将会影响数据包归并及分片时候的最大传输单元。*/ 50 | ikcp_setmtu(kcp, mtu);//可能还要浪费几个字节 51 | 52 | /*最小RTO:不管是 TCP还是 KCP计算 RTO时都有最小 RTO的限制,即便计算出来RTO为40ms,由于默认的 RTO是100ms,协议只有在100ms后才能检测到丢包,快速模式下为30ms,可以手动更改该值:*/ 53 | //kcp->rx_minrto = 100; 54 | kcp->rx_minrto = KcpSetting.Default.RTO; 55 | } 56 | else 57 | { 58 | x.EncoderData = null; 59 | throw new InvalidCastException($"kcp create failed {(int)errno}"); 60 | } 61 | } 62 | } 63 | 64 | 65 | public override void Close() 66 | { 67 | if (x.EncoderData != null) 68 | { 69 | Console.WriteLine($"release kcp {(int)x.EncoderData}"); 70 | ikcp_release(x.EncoderData); 71 | x.EncoderData = null; 72 | } 73 | Console.WriteLine("kcp encoder close"); 74 | } 75 | } 76 | 77 | public unsafe class KcpCodecEx : KcpCodec 78 | { 79 | public KcpCodecEx(PeerContext x) : base(x) 80 | { 81 | } 82 | public override int MaxKcpPackSize => Utilities.PackSettings.MAX_DATA_LEN - 1; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/IOServer.cs: -------------------------------------------------------------------------------- 1 | using DotNetty.Buffers; 2 | using DotNetty.Transport.Bootstrapping; 3 | using DotNetty.Transport.Channels; 4 | using DotNetty.Transport.Channels.Sockets; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Net; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace KcpServer 13 | { 14 | internal class IOServer 15 | { 16 | public Action DebugLog = (string s) => 17 | { 18 | #if DEBUG 19 | Console.WriteLine(s); 20 | #endif 21 | }; 22 | //if tcp use ServerBootstrap 23 | Bootstrap bootstrap; 24 | //IChannel channel; 25 | IEventLoopGroup iogroup; 26 | 27 | public IChannel Channel { get; private set; } 28 | 29 | public EndPoint LocalEndPoint { get => Channel?.LocalAddress; } 30 | //if tcp you need workers 31 | //IEventLoopGroup workergroup; 32 | internal Task InitServerAsync(ChannelHandlerAdapter handler, IPEndPoint localipep,Action afterchannel) 33 | { 34 | iogroup = new MultithreadEventLoopGroup(); 35 | //workergroup = new MultithreadEventLoopGroup(); 36 | try 37 | { 38 | if (bootstrap != null) 39 | { 40 | throw new InvalidOperationException("重复init"); 41 | } 42 | bootstrap = new Bootstrap(); 43 | bootstrap.Group(iogroup) 44 | .Channel() 45 | .Option(ChannelOption.SoBroadcast, true) 46 | .Handler(handler); 47 | var _channel = bootstrap.BindAsync(localipep); 48 | //channel = _channel.Result; 49 | _channel.ContinueWith((c) => 50 | { 51 | var ch = c.Result; 52 | this.Channel = ch; 53 | if (ch.LocalAddress is IPEndPoint ipep) 54 | { 55 | IPAddress[] ipaddrs = Dns.GetHostAddresses(Environment.MachineName); 56 | foreach (var ipaddr in ipaddrs) 57 | { 58 | DebugLog(ipaddr.ToString()); 59 | } 60 | } 61 | DebugLog($"inited {ch.LocalAddress}"); 62 | afterchannel.Invoke(); 63 | }); 64 | return Task.FromResult(true); 65 | } 66 | catch (System.Threading.ThreadInterruptedException e) 67 | { 68 | DebugLog(e.ToString()); 69 | DebugLog("shutdown"); 70 | iogroup.ShutdownGracefullyAsync(); 71 | } 72 | return Task.FromResult(false); 73 | } 74 | 75 | internal Task CloseAsync() 76 | { 77 | return iogroup.ShutdownGracefullyAsync(); 78 | } 79 | } 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/KCPClasses/KcpPeerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using k = kcpwarpper; 7 | using static kcpwarpper.KCP; 8 | using System.Runtime.InteropServices; 9 | using Utilities; 10 | 11 | namespace KcpServer 12 | { 13 | public unsafe abstract class KcpPeerBase : PeerBase 14 | { 15 | k.IKCPCB* kcp 16 | { 17 | get 18 | { 19 | return pc.EncoderData; 20 | } 21 | } 22 | k.d_output realsend; 23 | PeerContext pc; 24 | public KcpPeerBase(PeerContext pc) : base(pc) 25 | { 26 | this.pc = pc; 27 | //kcp create放在这里比较合适 28 | if (kcp == null) 29 | { 30 | throw new NullReferenceException("kcp codec lost"); 31 | } 32 | realsend = new k.d_output(udp_output); 33 | pc.EncoderData->output = Marshal.GetFunctionPointerForDelegate(realsend); 34 | } 35 | protected virtual int udp_output(byte* buf, int len, k.IKCPCB* kcp, void* user) 36 | { 37 | byte[] kcppack = new byte[len]; 38 | Marshal.Copy(new IntPtr(buf), kcppack, 0, len); 39 | #if PRINTPACK 40 | Console.WriteLine($"kcp_output:size{kcppack.Length}:{string.Join(",", kcppack)}"); 41 | #endif 42 | var sendbuf = new byte[PackSettings.HEADER_LEN + kcppack.Length]; 43 | defpb.Write(sendbuf, kcppack, 0, kcppack.Length); 44 | OutgoingData.Enqueue(sendbuf); 45 | return 0; 46 | } 47 | protected override void BeforeOperationRequest(byte[] buf) 48 | { 49 | #if PRINTPACK 50 | Console.WriteLine($"ikcp_input:size{buf.Length}:{string.Join(",", buf)}"); 51 | Console.WriteLine($"rec:{buf.Length}"); 52 | #endif 53 | fixed (byte* p = &buf[0]) 54 | { 55 | ikcp_input(this.Context.EncoderData, p, buf.Length); 56 | } 57 | } 58 | 59 | protected override void BeforeSendOutgoing(byte[] data) 60 | { 61 | if (kcp == null) return; 62 | fixed (byte* b = &data[0]) 63 | { 64 | ikcp_send(this.Context.EncoderData, b, data.Length); 65 | } 66 | } 67 | byte[] recbuf = new byte[Utilities.PackSettings.MAX_RECBUFF_LEN]; 68 | protected override void DeriverUpdate() 69 | { 70 | if (kcp == null) return; 71 | fixed (byte* b = &recbuf[0]) 72 | { 73 | int kcnt = 0; 74 | do 75 | { 76 | kcnt = ikcp_recv(kcp, b, recbuf.Length); 77 | if (kcnt > 0) 78 | { 79 | byte[] data = new byte[kcnt]; 80 | Array.Copy(recbuf, data, kcnt); 81 | OnOperationRequest(data); 82 | 83 | } 84 | } while (kcnt > 0); 85 | } 86 | ikcp_update(kcp, (uint)Environment.TickCount); 87 | } 88 | 89 | public void KcpFlush() 90 | { 91 | if (kcp == null) 92 | { 93 | return; 94 | } 95 | ikcp_flush(kcp); 96 | } 97 | 98 | public int WaitSend 99 | { 100 | get 101 | { 102 | if (kcp != null) 103 | { 104 | return ikcp_waitsnd(kcp); 105 | } 106 | return -1; 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/KCPClasses/KcpPeerEx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using k = kcpwarpper; 7 | using static kcpwarpper.KCP; 8 | using System.Runtime.InteropServices; 9 | using Utilities; 10 | 11 | namespace KcpServer 12 | { 13 | /// 14 | /// 这个支持不可靠协议 15 | /// 16 | public unsafe abstract class KcpPeerEx : KcpPeerBase 17 | { 18 | public KcpPeerEx(PeerContext pc) : base(pc) { } 19 | protected override unsafe int udp_output(byte* buf, int len, k.IKCPCB* kcp, void* user) 20 | { 21 | //一定是reliable 22 | byte[] kcppack = new byte[len + 1]; 23 | Marshal.Copy(new IntPtr(buf), kcppack, 1, len); 24 | kcppack[0] = (byte)PackType.Kcp; 25 | #if PRINTPACK 26 | Console.WriteLine($"kcp_output:size{kcppack.Length}:{string.Join(",", kcppack)}"); 27 | #endif 28 | var sendbuf = new byte[PackSettings.HEADER_LEN + kcppack.Length]; 29 | defpb.Write(sendbuf, kcppack, 0, kcppack.Length); 30 | OutgoingData.Enqueue(sendbuf); 31 | return 0; 32 | } 33 | protected override void BeforeOperationRequest(byte[] buf) 34 | { 35 | #if PRINTPACK 36 | Console.WriteLine($"ikcp_input:size{buf.Length}:{string.Join(",", buf)}"); 37 | Console.WriteLine($"rec:{buf.Length}"); 38 | #endif 39 | if (buf.Length > 0) 40 | { 41 | var type = (Utilities.PackType)buf[0]; 42 | switch (type) 43 | { 44 | case PackType.Udp: 45 | var data = new byte[buf.Length - 1]; 46 | Array.Copy(buf, 1, data, 0, data.Length); 47 | OnOperationRequest(data); 48 | break; 49 | case PackType.Kcp: 50 | fixed (byte* p = &buf[1]) 51 | { 52 | ikcp_input(this.Context.EncoderData, p, buf.Length - 1); 53 | } 54 | break; 55 | default: 56 | throw new UnknownTypeException("unknown packtype"); 57 | break; 58 | } 59 | } 60 | } 61 | 62 | protected override void BeforeSendOutgoing(byte[] data) 63 | { 64 | //这里的data已经不是用户数据,已经包含了reliable 65 | var type = (Utilities.PackType)data[0]; 66 | switch (type) 67 | { 68 | case PackType.Udp: 69 | var sendbuf = new byte[PackSettings.HEADER_LEN + data.Length]; 70 | defpb.Write(sendbuf, data, 0, data.Length); 71 | OutgoingData.Enqueue(sendbuf); 72 | break; 73 | case PackType.Kcp: 74 | if (this.Context.EncoderData == null) 75 | { 76 | return; 77 | } 78 | //交给kcp需要去掉第一个字节,不是直接发 79 | fixed (byte* b = &data[1]) 80 | { 81 | ikcp_send(this.Context.EncoderData, b, data.Length - 1); 82 | } 83 | break; 84 | default: 85 | throw new UnknownTypeException("unknown packtype"); 86 | break; 87 | } 88 | } 89 | 90 | public override void SendOperationResponse(byte[] data) 91 | { 92 | SendOperationResponse(data, false); 93 | } 94 | public void SendOperationResponse(byte[] data, bool unreliable) 95 | { 96 | if (!_connected) return; 97 | var senddata = new byte[data.Length + 1]; 98 | Array.Copy(data, 0, senddata, 1, data.Length); 99 | if (unreliable) 100 | { 101 | senddata[0] = (byte)Utilities.PackType.Udp; 102 | } 103 | else 104 | { 105 | senddata[0] = (byte)Utilities.PackType.Kcp; 106 | } 107 | BeforeSendOutgoing(senddata); 108 | } 109 | } 110 | 111 | public class UnknownTypeException : Exception 112 | { 113 | public UnknownTypeException() 114 | { 115 | 116 | } 117 | public UnknownTypeException(string s) : base(s) 118 | { 119 | 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/KCPClasses/KcpServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using DotNetty.Transport.Channels; 7 | 8 | namespace KcpServer 9 | { 10 | public class KcpServer : UdpServer 11 | { 12 | protected override ChannelHandlerAdapter GetServerHandler(ConnectionManager cm) 13 | { 14 | return new KcpServerHandler(cm); 15 | } 16 | } 17 | public class KcpServerEx : KcpServer 18 | { 19 | protected override ChannelHandlerAdapter GetServerHandler(ConnectionManager cm) 20 | { 21 | return new KcpServerExHandler(cm); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/KCPClasses/KcpServerHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace KcpServer 8 | { 9 | public class KcpServerHandler : UdpServerHandler 10 | { 11 | public KcpServerHandler(ConnectionManager man) : base(man) 12 | { 13 | DebugLog($"ctor {nameof(KcpServerHandler)}"); 14 | } 15 | 16 | protected override void BuildCodecsBeforePlayerCreated(PeerContext x) 17 | { 18 | DebugLog($"kcp {nameof(BuildCodecsBeforePlayerCreated)}"); 19 | x.Codec = new Codec.KcpCodec(x); 20 | } 21 | } 22 | public class KcpServerExHandler : UdpServerHandler 23 | { 24 | public KcpServerExHandler(ConnectionManager man) : base(man) 25 | { 26 | DebugLog($"ctor {nameof(KcpServerExHandler)}"); 27 | } 28 | 29 | protected override void BuildCodecsBeforePlayerCreated(PeerContext x) 30 | { 31 | DebugLog($"kcp {nameof(BuildCodecsBeforePlayerCreated)}"); 32 | x.Codec = new Codec.KcpCodecEx(x); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/KcpSetting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace KcpServer 7 | { 8 | public class KcpSetting 9 | { 10 | public int RecWindowSize { get; set; } = 128; 11 | public int SndWindowSize { get; set; } = 128; 12 | /// 13 | /// 是否启用 nodelay模式,0不启用;1启用。 14 | /// 15 | public int NoDelay { get; set; } = 1; 16 | 17 | /// 18 | /// 协议内部工作的 interval,单位毫秒,比如 10ms或者 20ms 19 | /// 20 | public int NoDelayInterval { get; set; } = 10; 21 | /// 22 | /// 重发跨越包数量,2表示两次ack跨越直接重新传 23 | /// 24 | public int NoDelayResend { get; set; } = 2; 25 | /// 26 | /// 是否启用流量控制 27 | /// 28 | public int NoDelayNC { get; set; } = 1; 29 | //public int NoDelay { get; set; } = 1; 30 | /// 31 | /// 检测丢包的时间间隔,RTO时都有最小 RTO的限制,即便计算出来RTO为40ms,由于默认的 RTO是100ms,协议只有在100ms后才能检测到丢包,快速模式下为30ms,可以手动更改该值 32 | /// 33 | public int RTO { get; set; } = 100; 34 | 35 | 36 | 37 | private KcpSetting() 38 | { 39 | 40 | } 41 | 42 | static KcpSetting _setting = new KcpSetting(); 43 | 44 | public static KcpSetting Default 45 | { 46 | get 47 | { 48 | return _setting; 49 | } 50 | } 51 | 52 | public int MTU { get; set; } = Utilities.PackSettings.MAX_DATA_LEN; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/PeerContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using System.Net; 3 | using KcpServer.Codec; 4 | using kcpwarpper; 5 | 6 | namespace KcpServer 7 | { 8 | /// 9 | /// 用于保存建立连接时候的信息 10 | /// 11 | public class PeerContext 12 | { 13 | internal unsafe IKCPCB* EncoderData; 14 | 15 | public PeerContext() 16 | { 17 | } 18 | 19 | public byte[] ApplicationData { get; set; } 20 | public EndPoint RemoteEP { get; set; } 21 | public EndPoint LocalEP { get; set; } 22 | public int SessionId { get; internal set; } 23 | public ConnectionManager ConnectionManager { get; internal set; } 24 | public CodecBase Codec { get; internal set; } 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /KcpServer/KcpServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpServer/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /KcpServer/KcpServer/ServerConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Utilities; 8 | 9 | namespace KcpServer 10 | { 11 | public class ServerConfig 12 | { 13 | private byte[] _sysId; 14 | private byte[] _appId; 15 | private ApplicationBase _app; 16 | private TimeSpan _timeout; 17 | private FiberPool _fp; 18 | private IPEndPoint _localipep; 19 | private int _maxPlayer = 20; 20 | 21 | private bool _blocking = false; 22 | 23 | public byte[] SysId { get => _sysId;/* set => sysId = value;*/ } 24 | public byte[] AppId { get => _appId; /*set => _appId = value;*/ } 25 | public ApplicationBase App { get => _app; /*set => _app = value;*/ } 26 | public TimeSpan Timeout { get => _timeout; /*set => _timeout = value;*/ } 27 | public FiberPool Fp { get => _fp; /*set => _fp = value; */} 28 | public IPEndPoint Localipep { get => _localipep; /*set => _localipep = value;*/ } 29 | internal int MaxPlayer { get => _maxPlayer; /*set => maxPlayer = value; */} 30 | [Obsolete("无效属性,用于兼容Lite")] 31 | public bool Blocking { get => _blocking; } 32 | public ServerConfig SetSysId(byte[] _4BytesId) 33 | { 34 | this._sysId = _4BytesId; 35 | return this; 36 | } 37 | 38 | public ServerConfig SetApplicationData(byte[] appId) 39 | { 40 | this._appId = appId; 41 | return this; 42 | } 43 | 44 | public ServerConfig BindApplication(ApplicationBase app) 45 | { 46 | this._app = app; 47 | return this; 48 | } 49 | 50 | public ServerConfig SetTimeout(TimeSpan timeSpan) 51 | { 52 | this._timeout = timeSpan; 53 | return this; 54 | } 55 | 56 | public ServerConfig SetFiberPool(FiberPool fp) 57 | { 58 | this._fp = fp; 59 | return this; 60 | } 61 | 62 | public ServerConfig SetLocalIpep(IPEndPoint localipep) 63 | { 64 | this._localipep = localipep; 65 | return this; 66 | } 67 | 68 | 69 | public static ServerConfig Create() 70 | { 71 | return new ServerConfig(); 72 | } 73 | 74 | public ServerConfig SetMaxPlayer(int maxplayer) 75 | { 76 | this._maxPlayer = maxplayer; 77 | return this; 78 | } 79 | [Obsolete("无效属性,用于兼容Lite")] 80 | public ServerConfig SetBlocking(bool blocking) 81 | { 82 | this._blocking = blocking; 83 | return this; 84 | } 85 | 86 | private ServerConfig() 87 | { 88 | 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/UdpServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Utilities; 9 | 10 | namespace KcpServer 11 | { 12 | public class UdpServer 13 | { 14 | public Action DebugLog = (s) => 15 | { 16 | #if DEBUG 17 | Console.WriteLine(s); 18 | #endif 19 | }; 20 | 21 | IOServer server = new IOServer(); 22 | ConnectionManager cm; 23 | TaskFactory tf = new TaskFactory(); 24 | public EndPoint LocalEndPoint { get => server.LocalEndPoint; } 25 | public Task AsyncStart(ServerConfig sc) 26 | { 27 | 28 | cm = ConnectionManager.Create(sc.MaxPlayer) 29 | .SetSysId(sc.SysId) 30 | .SetApplicationData(sc.AppId) 31 | .BindApplication(sc.App) 32 | .SetTimeout(sc.Timeout) 33 | .SetFiberPool(sc.Fp) 34 | ; 35 | 36 | var t = server.InitServerAsync(GetServerHandler(cm), sc.Localipep,()=> { 37 | sc.App.SetLocalEndPoint(server.LocalEndPoint); 38 | sc.App.Setup(); 39 | }); 40 | t.Wait(); 41 | var t2 = t.ContinueWith((a) => 42 | { 43 | if (a.Result == false) 44 | { 45 | DebugLog("init error"); 46 | } 47 | else 48 | { 49 | tf.StartNew(() => UpdatePeersThreadLoop(cm), TaskCreationOptions.LongRunning); 50 | } 51 | }, TaskContinuationOptions.AttachedToParent); 52 | 53 | //var t3 = t.ContinueWith((a) => 54 | //{ 55 | // if (a.Result == false) 56 | // { 57 | // DebugLog("init error"); 58 | // } 59 | // else 60 | // { 61 | // //sc.App.SetLocalEndPoint(server.LocalEndPoint); 62 | // //sc.App.Setup(); 63 | // } 64 | 65 | //}, TaskContinuationOptions.AttachedToParent); 66 | return t2; 67 | } 68 | 69 | public Task AsyncClose(TimeSpan closeTimeout) 70 | { 71 | var t = tf.StartNew(() => { cm.SyncClose(closeTimeout); }); 72 | var t2 = t.ContinueWith((a) => server.CloseAsync()); 73 | return t2; 74 | } 75 | 76 | void UpdatePeersThreadLoop(ConnectionManager cm) 77 | { 78 | SpinWait sw = new SpinWait(); 79 | while (cm.App.ApplicationRunning) 80 | { 81 | cm.CheckTimeout(); 82 | sw.SpinOnce(); 83 | } 84 | } 85 | 86 | protected virtual DotNetty.Transport.Channels.ChannelHandlerAdapter GetServerHandler(ConnectionManager cm) 87 | { 88 | return new UdpServerHandler(cm); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /KcpServer/KcpServer/kcpwarpper.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpServer/kcpwarpper.dll -------------------------------------------------------------------------------- /KcpServer/KcpServer/libikcp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/KcpServer/libikcp.dll -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/ApplicationBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace KcpServer.Lite 9 | { 10 | public abstract class ApplicationBase 11 | { 12 | ConnectionManager ConnMan; 13 | private EndPoint _localEndPoint; 14 | 15 | internal void SetConnMan(ConnectionManager cm) 16 | { 17 | ConnMan = cm; 18 | } 19 | 20 | public bool ApplicationRunning { get; internal set; } = true; 21 | public EndPoint LocalEndPoint { get => _localEndPoint; /*set => localEndPoint = value;*/ } 22 | 23 | public virtual bool PreCreatePeer(PeerContext peerContext) 24 | { 25 | return true; 26 | } 27 | /// 28 | /// if eject return null. 29 | /// 30 | /// 31 | public abstract PeerBase CreatePeer(PeerContext peerContext); 32 | 33 | public abstract void Setup(); 34 | 35 | public abstract void TearDown(); 36 | 37 | internal void Close() 38 | { 39 | if (ApplicationRunning) 40 | { 41 | TearDown(); 42 | ApplicationRunning = false; 43 | } 44 | } 45 | 46 | internal void SetLocalEndPoint(EndPoint localEndPoint) 47 | { 48 | this._localEndPoint = localEndPoint; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/Codec/CodecBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace KcpServer.Lite.Codec 8 | { 9 | public class CodecBase 10 | { 11 | public virtual void Close() 12 | { 13 | #if DEBUG 14 | Console.WriteLine($"{nameof(CodecBase)} {nameof(Close)}"); 15 | #endif 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/Codec/KcpCodec.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using static kcpwarpper.KCP; 8 | namespace KcpServer.Lite.Codec 9 | { 10 | public unsafe class KcpCodec : CodecBase 11 | { 12 | private PeerContext x; 13 | public KcpCodec(PeerContext x) 14 | { 15 | this.x = x; 16 | CreateKcp(x); 17 | 18 | } 19 | public virtual int MaxKcpPackSize { get => Utilities.PackSettings.MAX_DATA_LEN; } 20 | public void CreateKcp(PeerContext x) 21 | { 22 | if (x.EncoderData == null) 23 | { 24 | var errno = ikcp_create((uint)x.SessionId, (void*)0); 25 | if ((int)errno != -1) 26 | { 27 | x.EncoderData = errno; 28 | #if PRINTPACK 29 | Console.WriteLine($"create kcp {(int)x.EncoderData}"); 30 | #endif 31 | var kcp = x.EncoderData; 32 | /*该调用将会设置协议的最大发送窗口和最大接收窗口大小,默认为32. 这个可以理解为 TCP的 SND_BUF 和 RCV_BUF,只不过单位不一样 SND/RCV_BUF 单位是字节,这个单位是包。*/ 33 | 34 | //ikcp_wndsize(kcp, 128, 128); 35 | ikcp_wndsize(kcp, KcpSetting.Default.SndWindowSize, KcpSetting.Default.RecWindowSize); 36 | /* 37 | nodelay :是否启用 nodelay模式,0不启用;1启用。 38 | interval :协议内部工作的 interval,单位毫秒,比如 10ms或者 20ms 39 | resend :快速重传模式,默认0关闭,可以设置2(2次ACK跨越将会直接重传) 40 | nc :是否关闭流控,默认是0代表不关闭,1代表关闭。 41 | 普通模式:`ikcp_nodelay(kcp, 0, 40, 0, 0); 42 | 极速模式: ikcp_nodelay(kcp, 1, 10, 2, 1); 43 | */ 44 | //ikcp_nodelay(kcp, 1, 10, 2, 1); 45 | ikcp_nodelay(kcp, KcpSetting.Default.NoDelay, KcpSetting.Default.NoDelayInterval, KcpSetting.Default.NoDelayResend, KcpSetting.Default.NoDelayNC); 46 | int mtu = Math.Min(MaxKcpPackSize, KcpSetting.Default.MTU); 47 | /*最大传输单元:纯算法协议并不负责探测 MTU,默认 mtu是1400字节,可以使用ikcp_setmtu来设置该值。该值将会影响数据包归并及分片时候的最大传输单元。*/ 48 | ikcp_setmtu(kcp, mtu);//可能还要浪费几个字节 49 | 50 | /*最小RTO:不管是 TCP还是 KCP计算 RTO时都有最小 RTO的限制,即便计算出来RTO为40ms,由于默认的 RTO是100ms,协议只有在100ms后才能检测到丢包,快速模式下为30ms,可以手动更改该值:*/ 51 | //kcp->rx_minrto = 100; 52 | kcp->rx_minrto = KcpSetting.Default.RTO; 53 | } 54 | else 55 | { 56 | x.EncoderData = null; 57 | throw new InvalidCastException($"kcp create failed {(int)errno}"); 58 | } 59 | } 60 | } 61 | 62 | 63 | public override void Close() 64 | { 65 | if (x.EncoderData != null) 66 | { 67 | Console.WriteLine($"release kcp {(int)x.EncoderData}"); 68 | ikcp_release(x.EncoderData); 69 | x.EncoderData = null; 70 | } 71 | Console.WriteLine("kcp encoder close"); 72 | } 73 | } 74 | 75 | public unsafe class KcpCodecEx : KcpCodec 76 | { 77 | public KcpCodecEx(PeerContext x) : base(x) 78 | { 79 | } 80 | public override int MaxKcpPackSize => Utilities.PackSettings.MAX_DATA_LEN - 1; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/KCPClasses/KcpPeerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using k = kcpwarpper; 7 | using static kcpwarpper.KCP; 8 | using System.Runtime.InteropServices; 9 | using Utilities; 10 | 11 | namespace KcpServer.Lite 12 | { 13 | public unsafe abstract class KcpPeerBase : PeerBase 14 | { 15 | k.IKCPCB* kcp 16 | { 17 | get 18 | { 19 | return pc.EncoderData; 20 | } 21 | } 22 | k.d_output realsend; 23 | PeerContext pc; 24 | public KcpPeerBase(PeerContext pc) : base(pc) 25 | { 26 | this.pc = pc; 27 | //kcp create放在这里比较合适 28 | if (kcp == null) 29 | { 30 | throw new NullReferenceException("kcp codec lost"); 31 | } 32 | realsend = new k.d_output(udp_output); 33 | pc.EncoderData->output = Marshal.GetFunctionPointerForDelegate(realsend); 34 | } 35 | protected virtual int udp_output(byte* buf, int len, k.IKCPCB* kcp, void* user) 36 | { 37 | byte[] kcppack = new byte[len]; 38 | Marshal.Copy(new IntPtr(buf), kcppack, 0, len); 39 | #if PRINTPACK 40 | Console.WriteLine($"kcp_output:size{kcppack.Length}:{string.Join(",", kcppack)}"); 41 | #endif 42 | var sendbuf = new byte[PackSettings.HEADER_LEN + kcppack.Length]; 43 | defpb.Write(sendbuf, kcppack, 0, kcppack.Length); 44 | OutgoingData.Enqueue(sendbuf); 45 | return 0; 46 | } 47 | protected override void BeforeOperationRequest(byte[] buf) 48 | { 49 | #if PRINTPACK 50 | Console.WriteLine($"ikcp_input:size{buf.Length}:{string.Join(",", buf)}"); 51 | Console.WriteLine($"rec:{buf.Length}"); 52 | #endif 53 | fixed (byte* p = &buf[0]) 54 | { 55 | ikcp_input(this.Context.EncoderData, p, buf.Length); 56 | } 57 | } 58 | 59 | protected override void BeforeSendOutgoing(byte[] data) 60 | { 61 | if (kcp == null) return; 62 | fixed (byte* b = &data[0]) 63 | { 64 | ikcp_send(this.Context.EncoderData, b, data.Length); 65 | } 66 | } 67 | byte[] recbuf = new byte[Utilities.PackSettings.MAX_RECBUFF_LEN]; 68 | protected override void DeriverUpdate() 69 | { 70 | if (kcp == null) return; 71 | fixed (byte* b = &recbuf[0]) 72 | { 73 | int kcnt = 0; 74 | do 75 | { 76 | kcnt = ikcp_recv(kcp, b, recbuf.Length); 77 | if (kcnt > 0) 78 | { 79 | byte[] data = new byte[kcnt]; 80 | Array.Copy(recbuf, data, kcnt); 81 | OnOperationRequest(data); 82 | 83 | } 84 | } while (kcnt > 0); 85 | } 86 | ikcp_update(kcp, (uint)Environment.TickCount); 87 | } 88 | 89 | public void KcpFlush() 90 | { 91 | if (kcp == null) 92 | { 93 | return; 94 | } 95 | ikcp_flush(kcp); 96 | } 97 | public int WaitSend 98 | { 99 | get 100 | { 101 | if (kcp != null) 102 | { 103 | return ikcp_waitsnd(kcp); 104 | } 105 | return -1; 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/KCPClasses/KcpServerLite.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace KcpServer.Lite 8 | { 9 | /// 10 | /// 不创建任何线程或者Task,用于某些不能创建线程的环境.一切由外部信号驱动. 11 | /// 12 | public class KcpServerLite : UdpServerLite 13 | { 14 | protected override void BuildCodecsBeforePlayerCreated(PeerContext x) 15 | { 16 | DebugLog($"{nameof(Codec.KcpCodec)} {nameof(BuildCodecsBeforePlayerCreated)}"); 17 | x.Codec = new Codec.KcpCodec(x); 18 | } 19 | } 20 | public class KcpServerExLite : KcpServerLite 21 | { 22 | protected override void BuildCodecsBeforePlayerCreated(PeerContext x) 23 | { 24 | DebugLog($"{nameof(Codec.KcpCodecEx)} {nameof(BuildCodecsBeforePlayerCreated)}"); 25 | x.Codec = new Codec.KcpCodecEx(x); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/KcpServer.Lite.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CE068426-1F28-4C19-BD70-81DB22B1BCA2} 8 | Library 9 | Properties 10 | KcpServer.Lite 11 | KcpServer.Lite 12 | v4.6.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\x64\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | x64 24 | true 25 | 26 | 27 | pdbonly 28 | true 29 | bin\x64\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | x64 35 | 36 | 37 | 38 | False 39 | .\kcpwarpper.dll 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | KcpSetting.cs 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | kcpwarpper.dll 71 | Always 72 | 73 | 74 | kcpwarpper.pdb 75 | Always 76 | 77 | 78 | libikcp.dll 79 | Always 80 | 81 | 82 | libikcp.pdb 83 | Always 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/PeerContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using KcpServer.Lite.Codec; 8 | using kcpwarpper; 9 | 10 | namespace KcpServer.Lite 11 | { 12 | public unsafe class PeerContext 13 | { 14 | public byte[] ApplicationData { get; internal set; } 15 | public EndPoint RemoteEP { get; internal set; } 16 | public EndPoint LocalEP { get; internal set; } 17 | public int SessionId { get; internal set; } 18 | public ConnectionManager ConnectionManager { get; internal set; } 19 | public CodecBase Codec { get; internal set; } 20 | public IKCPCB* EncoderData { get; internal set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("KcpServerLite")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("KcpServerLite")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ce068426-1f28-4c19-bd70-81db22b1bca2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/SendChannel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace KcpServer.Lite 10 | { 11 | public class SendChannel 12 | { 13 | private Socket sock = null; 14 | public SendChannel(Socket udp) 15 | { 16 | sock = udp; 17 | } 18 | internal void Send(byte[] sendbuf, EndPoint remoteEP) 19 | { 20 | sock.SendTo(sendbuf, remoteEP); 21 | } 22 | internal bool CanSend => sock?.Poll(0, SelectMode.SelectWrite) == true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /KcpServer/KcpServerLite/ServerConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace KcpServer.Lite 9 | { 10 | public class ServerConfig 11 | { 12 | private byte[] _sysId; 13 | private byte[] _appId; 14 | private ApplicationBase _app; 15 | private TimeSpan _timeout; 16 | 17 | private IPEndPoint _localipep; 18 | private int _maxPlayer = 20; 19 | 20 | private bool _blocking = false; 21 | 22 | public byte[] SysId { get => _sysId;/* set => sysId = value;*/ } 23 | public byte[] AppId { get => _appId; /*set => _appId = value;*/ } 24 | public ApplicationBase App { get => _app; /*set => _app = value;*/ } 25 | public TimeSpan Timeout { get => _timeout; /*set => _timeout = value;*/ } 26 | 27 | public IPEndPoint Localipep { get => _localipep; /*set => _localipep = value;*/ } 28 | internal int MaxPlayer { get => _maxPlayer; /*set => maxPlayer = value; */} 29 | public bool Blocking { get => _blocking; } 30 | 31 | public ServerConfig SetSysId(byte[] _4BytesId) 32 | { 33 | this._sysId = _4BytesId; 34 | return this; 35 | } 36 | 37 | public ServerConfig SetApplicationData(byte[] appId) 38 | { 39 | this._appId = appId; 40 | return this; 41 | } 42 | 43 | public ServerConfig BindApplication(ApplicationBase app) 44 | { 45 | this._app = app; 46 | return this; 47 | } 48 | 49 | public ServerConfig SetTimeout(TimeSpan timeSpan) 50 | { 51 | this._timeout = timeSpan; 52 | return this; 53 | } 54 | 55 | 56 | 57 | public ServerConfig SetLocalIpep(IPEndPoint localipep) 58 | { 59 | this._localipep = localipep; 60 | return this; 61 | } 62 | 63 | 64 | public static ServerConfig Create() 65 | { 66 | return new ServerConfig(); 67 | } 68 | 69 | public ServerConfig SetMaxPlayer(int maxplayer) 70 | { 71 | this._maxPlayer = maxplayer; 72 | return this; 73 | } 74 | public ServerConfig SetBlocking(bool blocking) 75 | { 76 | this._blocking = blocking; 77 | return this; 78 | } 79 | 80 | private ServerConfig() 81 | { 82 | 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /KcpServer/TestClient/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /KcpServer/TestClient/ClientMix.cs: -------------------------------------------------------------------------------- 1 | extern alias globalclient; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Net; 9 | using System.Net.Sockets; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | using k =globalclient::KcpClient; 14 | using System.Runtime.InteropServices; 15 | using static Utilities.MakeTestBuff; 16 | namespace TestClient 17 | { 18 | public partial class ClientMix : Form 19 | { 20 | k.KcpClientEx client; 21 | IPEndPoint remoteipep; 22 | 23 | public ClientMix() 24 | { 25 | InitializeComponent(); 26 | } 27 | 28 | private void button_init_Click(object sender, EventArgs e) 29 | { 30 | if (client != null) 31 | { 32 | client.Close(); 33 | } 34 | client = new k.KcpClientEx("Test".ToCharArray().Select(a => (byte)a).ToArray(), 0, "mixpeer".ToCharArray().Select(a => (byte)a).ToArray()); 35 | var arr = textBox_remote.Text.Split(":"[0]); 36 | remoteipep = new IPEndPoint(IPAddress.Parse(arr[0]), int.Parse(arr[1])); 37 | client.OnOperationResponse = (buf) => 38 | { 39 | if (buf.Length == sizeof(UInt64)) 40 | { 41 | var i = BitConverter.ToInt64(buf, 0); 42 | Console.WriteLine($"rec unreliable:{i}"); 43 | } 44 | else 45 | { 46 | Console.WriteLine($"rec reliable {nameof(CheckBigBBuff)}={CheckBigBBuff(buf)} size:{buf.Length} "); 47 | } 48 | }; 49 | client.OnConnected = (sid) => 50 | { 51 | this.Invoke( 52 | new Action(() => 53 | { 54 | this.Text = sid.ToString(); 55 | }) 56 | ); 57 | 58 | }; 59 | 60 | client.Connect(remoteipep, true); 61 | } 62 | 63 | private void button_Send_Click(object sender, EventArgs e) 64 | { 65 | client?.SendOperationRequest(MakeBigBuff()); 66 | } 67 | 68 | private void button_send_unreliable_Click(object sender, EventArgs e) 69 | { 70 | client?.SendOperationRequest(BitConverter.GetBytes((UInt64)1), true); 71 | } 72 | 73 | private void button_close_Click(object sender, EventArgs e) 74 | { 75 | client?.Close(); 76 | } 77 | 78 | private void timer1_Tick(object sender, EventArgs e) 79 | { 80 | client?.Service(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /KcpServer/TestClient/ClientUdp.cs: -------------------------------------------------------------------------------- 1 | extern alias globalclient; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Net; 9 | using System.Net.Sockets; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | using k =globalclient::KcpClient; 14 | using System.Runtime.InteropServices; 15 | using static Utilities.MakeTestBuff; 16 | 17 | namespace TestClient 18 | { 19 | public partial class ClientUdp : Form 20 | { 21 | 22 | k.UdpClient client; 23 | IPEndPoint localipep; 24 | IPEndPoint remoteipep; 25 | public ClientUdp() 26 | { 27 | InitializeComponent(); 28 | } 29 | 30 | private void button_init_Click(object sender, EventArgs e) 31 | { 32 | if (client != null) 33 | { 34 | client.Close(); 35 | } 36 | client = new k.UdpClient("Test".ToCharArray().Select(a => (byte)a).ToArray(), 0, "udppeer".ToCharArray().Select(a => (byte)a).ToArray()); 37 | 38 | var arr = textBox_remote.Text.Split(":"[0]); 39 | remoteipep = new IPEndPoint(IPAddress.Parse(arr[0]), int.Parse(arr[1])); 40 | client.OnOperationResponse = (buf) => 41 | { 42 | var i = BitConverter.ToInt64(buf, 0); 43 | //Console.Write($"rec:{i}"); 44 | Task.Run(() => 45 | { 46 | var snd = i + 1; 47 | Console.WriteLine($"udp snd:{snd}"); 48 | client.SendOperationRequest(BitConverter.GetBytes(snd)); 49 | } 50 | ); 51 | }; 52 | client.OnConnected = (sid) => 53 | { 54 | this.Invoke( 55 | new Action(() => 56 | { 57 | this.Text = sid.ToString(); 58 | }) 59 | ); 60 | }; 61 | 62 | client.Connect(remoteipep, true); 63 | } 64 | 65 | private void button_close_Click(object sender, EventArgs e) 66 | { 67 | client?.Close(); 68 | } 69 | 70 | private void button_send_Click(object sender, EventArgs e) 71 | { 72 | client?.SendOperationRequest(BitConverter.GetBytes((UInt64)1)); 73 | } 74 | 75 | private void timer1_Tick(object sender, EventArgs e) 76 | { 77 | client?.Service(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /KcpServer/TestClient/Images/kcpserver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestClient/Images/kcpserver.png -------------------------------------------------------------------------------- /KcpServer/TestClient/Images/u3dclient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestClient/Images/u3dclient.png -------------------------------------------------------------------------------- /KcpServer/TestClient/Images/ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestClient/Images/ubuntu.png -------------------------------------------------------------------------------- /KcpServer/TestClient/Program.cs: -------------------------------------------------------------------------------- 1 | extern alias globalclient; 2 | 3 | using globalclient::KcpClient; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace TestClient 11 | { 12 | static class Program 13 | { 14 | /// 15 | /// The main entry point for the application. 16 | /// 17 | [STAThread] 18 | static void Main() 19 | { 20 | Application.EnableVisualStyles(); 21 | Application.SetCompatibleTextRenderingDefault(false); 22 | 23 | Form form=null; 24 | Console.WriteLine("All test:"); 25 | Console.WriteLine("1 PureUdp test"); 26 | Console.WriteLine("2 PureKcp test"); 27 | Console.WriteLine("3 Udp+Kcp mix test"); 28 | Console.WriteLine("4 PureKcp withflush minrto mix test"); 29 | Console.WriteLine("other: exit"); 30 | string input = ""; 31 | Console.WriteLine("input 1~4:"); 32 | input = Console.ReadLine(); 33 | switch (input.Trim()) 34 | { 35 | case "0": 36 | form = new ClientForm1(); 37 | break; 38 | case "1": 39 | form = new ClientUdp(); 40 | break; 41 | case "2": 42 | form = new ClientKcp(); 43 | break; 44 | case "3": 45 | form = new ClientMix(); 46 | break; 47 | case "4": 48 | KcpSetting.Default.RTO = 1; 49 | KcpSetting.Default.NoDelay = 1; 50 | KcpSetting.Default.NoDelayInterval = 1; 51 | KcpSetting.Default.NoDelayResend = 10; 52 | KcpSetting.Default.NoDelayNC = 1; 53 | KcpSetting.Default.SndWindowSize = 2048; 54 | KcpSetting.Default.RecWindowSize = 2048; 55 | KcpSetting.Default.MTU = Utilities.PackSettings.MAX_DATA_LEN; 56 | form = new ClientKcp(); 57 | break; 58 | default: 59 | return; 60 | break; 61 | } 62 | 63 | Application.Run(form); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /KcpServer/TestClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestClient/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /KcpServer/TestClient/Properties/Resources.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 TestClient.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 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 | /// Returns the cached ResourceManager instance used by this class. 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("TestClient.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 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 | -------------------------------------------------------------------------------- /KcpServer/TestClient/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 TestClient.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 | -------------------------------------------------------------------------------- /KcpServer/TestClient/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace TestServer.Lite 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, 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 Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.button_start = new System.Windows.Forms.Button(); 33 | this.textBox1 = new System.Windows.Forms.TextBox(); 34 | this.timer1 = new System.Windows.Forms.Timer(this.components); 35 | this.label1 = new System.Windows.Forms.Label(); 36 | this.SuspendLayout(); 37 | // 38 | // button_start 39 | // 40 | this.button_start.Location = new System.Drawing.Point(200, 12); 41 | this.button_start.Name = "button_start"; 42 | this.button_start.Size = new System.Drawing.Size(75, 23); 43 | this.button_start.TabIndex = 3; 44 | this.button_start.Text = "start"; 45 | this.button_start.UseVisualStyleBackColor = true; 46 | this.button_start.Click += new System.EventHandler(this.button_start_Click); 47 | // 48 | // textBox1 49 | // 50 | this.textBox1.Location = new System.Drawing.Point(12, 12); 51 | this.textBox1.Name = "textBox1"; 52 | this.textBox1.Size = new System.Drawing.Size(182, 21); 53 | this.textBox1.TabIndex = 2; 54 | this.textBox1.Text = "0.0.0.0:1000"; 55 | // 56 | // timer1 57 | // 58 | this.timer1.Enabled = true; 59 | this.timer1.Interval = 1; 60 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick); 61 | // 62 | // label1 63 | // 64 | this.label1.AutoSize = true; 65 | this.label1.Location = new System.Drawing.Point(22, 53); 66 | this.label1.Name = "label1"; 67 | this.label1.Size = new System.Drawing.Size(185, 12); 68 | this.label1.TabIndex = 4; 69 | this.label1.Text = "all update use winform timer. "; 70 | // 71 | // Form1 72 | // 73 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 74 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 75 | this.ClientSize = new System.Drawing.Size(407, 102); 76 | this.Controls.Add(this.label1); 77 | this.Controls.Add(this.button_start); 78 | this.Controls.Add(this.textBox1); 79 | this.Name = "Form1"; 80 | this.Text = "Form1"; 81 | this.ResumeLayout(false); 82 | this.PerformLayout(); 83 | 84 | } 85 | 86 | #endregion 87 | 88 | private System.Windows.Forms.Button button_start; 89 | private System.Windows.Forms.TextBox textBox1; 90 | private System.Windows.Forms.Timer timer1; 91 | private System.Windows.Forms.Label label1; 92 | } 93 | } 94 | 95 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/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.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using KcpServer.Lite; 11 | using System.Net; 12 | using static TestServer.Lite.Program; 13 | namespace TestServer.Lite 14 | { 15 | public partial class Form1 : Form 16 | { 17 | public Form1() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | 23 | private void button_start_Click(object sender, EventArgs e) 24 | { 25 | if (Server != null) 26 | { 27 | throw new InvalidOperationException("Already started"); 28 | } 29 | var arr = textBox1.Text.Split(":"[0]); 30 | int port = 1000; 31 | if (arr.Length > 1) 32 | { 33 | port = int.Parse(arr[1]); 34 | } 35 | IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(arr[0]), port); 36 | StartServer(ipep); 37 | } 38 | 39 | private void timer1_Tick(object sender, EventArgs e) 40 | { 41 | Server?.Service(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestServer.Lite")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestServer.Lite")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3e2d3729-f6d7-44a8-b979-31dab307a62e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/Properties/Resources.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 TestServer.Lite.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 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 | /// Returns the cached ResourceManager instance used by this class. 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("TestServer.Lite.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 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 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/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 TestServer.Lite.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 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/TestApplication.cs: -------------------------------------------------------------------------------- 1 | using KcpServer.Lite; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace TestServer.Lite 9 | { 10 | public class TestApplication : ApplicationBase 11 | { 12 | public override PeerBase CreatePeer(PeerContext peerContext) 13 | { 14 | var peertype = Encoding.UTF8.GetString(peerContext.ApplicationData); 15 | if (peertype == "udppeer") 16 | { 17 | return new TestUdpPeer(peerContext); 18 | } 19 | else if (peertype == "kcppeer") 20 | { 21 | return new BigBuffPeer(peerContext); 22 | } 23 | else if (peertype == "mixpeer") 24 | { 25 | return new ExPeer(peerContext); 26 | } 27 | else if (peertype == "kcppeerflush") 28 | { 29 | return new BigBuffPeerFlush(peerContext); 30 | } 31 | else 32 | { 33 | Console.WriteLine($"NotImplementedPeer"); 34 | return null; 35 | } 36 | } 37 | 38 | public override void Setup() 39 | { 40 | Console.WriteLine($"{nameof(TestApplication)} {nameof(Setup)} {LocalEndPoint}"); 41 | } 42 | 43 | public override void TearDown() 44 | { 45 | Console.WriteLine($"{nameof(TestApplication)} {nameof(TearDown)}"); 46 | } 47 | 48 | 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/TestPeer.cs: -------------------------------------------------------------------------------- 1 | using KcpServer.Lite; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using static Utilities.MakeTestBuff; 8 | namespace TestServer.Lite 9 | { 10 | class TestUdpPeer : PeerBase 11 | { 12 | public TestUdpPeer(PeerContext pc) : base(pc) 13 | { 14 | Console.WriteLine($"{nameof(TestUdpPeer)} sid:{pc.SessionId} created"); 15 | } 16 | 17 | public override void OnOperationRequest(byte[] data) 18 | { 19 | var i = BitConverter.ToInt64(data, 0); 20 | var snd = i + 1; 21 | this.SendOperationResponse(BitConverter.GetBytes(snd)); 22 | Console.WriteLine($"sid:{this.SessionId}->rec:{i} snd:{snd}"); 23 | } 24 | } 25 | 26 | class TestUdpPeer2 : PeerBase 27 | { 28 | public TestUdpPeer2(PeerContext pc) : base(pc) 29 | { 30 | Console.WriteLine($"{nameof(TestUdpPeer2)} sid:{pc.SessionId} created"); 31 | } 32 | 33 | public override void OnOperationRequest(byte[] data) 34 | { 35 | this.SendOperationResponse(data); 36 | } 37 | } 38 | public class BigBuffPeer : KcpPeerBase 39 | { 40 | public BigBuffPeer(PeerContext pc) : base(pc) 41 | { 42 | Console.WriteLine($"{nameof(BigBuffPeer)} sid:{pc.SessionId} created"); 43 | } 44 | 45 | public override void OnOperationRequest(byte[] data) 46 | { 47 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(data)} size:{data.Length}"); 48 | //send back to client 49 | SendOperationResponse(data); 50 | } 51 | } 52 | 53 | public class BigBuffPeerFlush : KcpPeerBase 54 | { 55 | public BigBuffPeerFlush(PeerContext pc) : base(pc) 56 | { 57 | Console.WriteLine($"{nameof(BigBuffPeerFlush)} sid:{pc.SessionId} created"); 58 | } 59 | 60 | public override void OnOperationRequest(byte[] data) 61 | { 62 | if (data.Length > sizeof(UInt64)) 63 | { 64 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(data)} size:{data.Length}"); 65 | } 66 | 67 | //send back to client 68 | SendOperationResponse(data); 69 | KcpFlush(); 70 | } 71 | } 72 | public class ExPeer : KcpPeerEx 73 | { 74 | public ExPeer(PeerContext pc) : base(pc) 75 | { 76 | Console.WriteLine($"{nameof(ExPeer)} sid:{pc.SessionId} created"); 77 | } 78 | 79 | public override void OnOperationRequest(byte[] data) 80 | { 81 | //貌似这里不知道是不是非可靠消息传递过来的,没有暴露到接口层面。不过貌似意义不大,反正收到了指令,在乎这个指令是怎么来的吗? 82 | if (data.Length==sizeof(UInt64)) 83 | { 84 | var i = BitConverter.ToInt64(data, 0); 85 | var snd = i + 1; 86 | this.SendOperationResponse(BitConverter.GetBytes(snd),true); 87 | Console.WriteLine($"sid:{this.SessionId}->rec:{i} snd:{snd}"); 88 | } 89 | else 90 | { 91 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(data)} size:{data.Length}"); 92 | //send back to client 93 | SendOperationResponse(data); 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /KcpServer/TestServer.Lite/TestServer.Lite.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3E2D3729-F6D7-44A8-B979-31DAB307A62E} 8 | Exe 9 | TestServer.Lite 10 | TestServer.Lite 11 | v4.6.2 12 | 512 13 | true 14 | 15 | 16 | x64 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Form 55 | 56 | 57 | Form1.cs 58 | 59 | 60 | 61 | 62 | 63 | Form1.cs 64 | 65 | 66 | ResXFileCodeGenerator 67 | Resources.Designer.cs 68 | Designer 69 | 70 | 71 | True 72 | Resources.resx 73 | 74 | 75 | SettingsSingleFileGenerator 76 | Settings.Designer.cs 77 | 78 | 79 | True 80 | Settings.settings 81 | True 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | {ce068426-1f28-4c19-bd70-81db22b1bca2} 90 | KcpServer.Lite 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /KcpServer/TestServer.LiteCore/TestServer.LiteCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | exe 5 | 6 | 7 | 8 | netcoreapp2.0 9 | 10 | exe 11 | 12 | 13 | 14 | 15 | x64 16 | True 17 | 18 | 19 | 20 | true 21 | x64 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /KcpServer/TestServer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /KcpServer/TestServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestServer")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3c634ee3-7558-4393-91f7-cb34de76a5e9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /KcpServer/TestServer/Properties/Resources.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 TestServer.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 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 | /// Returns the cached ResourceManager instance used by this class. 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("TestServer.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 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 | -------------------------------------------------------------------------------- /KcpServer/TestServer/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 TestServer.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 | -------------------------------------------------------------------------------- /KcpServer/TestServer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KcpServer/TestServer/ServerForm1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace TestServer 2 | { 3 | partial class ServerForm1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, 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 Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.button_start = new System.Windows.Forms.Button(); 33 | this.SuspendLayout(); 34 | // 35 | // textBox1 36 | // 37 | this.textBox1.Location = new System.Drawing.Point(0, 0); 38 | this.textBox1.Name = "textBox1"; 39 | this.textBox1.Size = new System.Drawing.Size(182, 21); 40 | this.textBox1.TabIndex = 0; 41 | this.textBox1.Text = "0.0.0.0:1000"; 42 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); 43 | // 44 | // button_start 45 | // 46 | this.button_start.Location = new System.Drawing.Point(188, 0); 47 | this.button_start.Name = "button_start"; 48 | this.button_start.Size = new System.Drawing.Size(75, 23); 49 | this.button_start.TabIndex = 1; 50 | this.button_start.Text = "start"; 51 | this.button_start.UseVisualStyleBackColor = true; 52 | this.button_start.Click += new System.EventHandler(this.button_start_Click); 53 | // 54 | // ServerForm1 55 | // 56 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 57 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 58 | this.ClientSize = new System.Drawing.Size(403, 82); 59 | this.Controls.Add(this.button_start); 60 | this.Controls.Add(this.textBox1); 61 | this.Name = "ServerForm1"; 62 | this.Text = "SForm1"; 63 | this.ResumeLayout(false); 64 | this.PerformLayout(); 65 | 66 | } 67 | 68 | #endregion 69 | 70 | private System.Windows.Forms.TextBox textBox1; 71 | private System.Windows.Forms.Button button_start; 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /KcpServer/TestServer/ServerForm1.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.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | using static TestServer.Program; 12 | namespace TestServer 13 | { 14 | public partial class ServerForm1 : Form 15 | { 16 | public ServerForm1() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void button_start_Click(object sender, EventArgs e) 22 | { 23 | if (Server != null) 24 | { 25 | throw new InvalidOperationException("Already started"); 26 | } 27 | var arr = textBox1.Text.Split(":"[0]); 28 | int port = 1000; 29 | if (arr.Length > 1) 30 | { 31 | port = int.Parse(arr[1]); 32 | } 33 | IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(arr[0]), port); 34 | StartServer(ipep); 35 | 36 | } 37 | 38 | private void textBox1_TextChanged(object sender, EventArgs e) 39 | { 40 | 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /KcpServer/TestServer/TestApplication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using KcpServer; 7 | 8 | namespace TestServer 9 | { 10 | class TestApplication : KcpServer.ApplicationBase 11 | { 12 | public override PeerBase CreatePeer(PeerContext peerContext) 13 | { 14 | var peertype = Encoding.UTF8.GetString(peerContext.ApplicationData); 15 | if (peertype == "udppeer") 16 | { 17 | return new TestUdpPeer(peerContext); 18 | } 19 | else if (peertype == "kcppeer") 20 | { 21 | return new BigBuffPeer(peerContext); 22 | } 23 | else if (peertype == "mixpeer") 24 | { 25 | return new ExPeer(peerContext); 26 | } 27 | else if (peertype == "kcppeerflush") 28 | { 29 | return new BigBuffPeerFlush(peerContext); 30 | } 31 | else 32 | { 33 | Console.WriteLine($"NotImplementedPeer"); 34 | return null; 35 | } 36 | } 37 | 38 | public override void Setup() 39 | { 40 | Console.WriteLine($"{nameof(TestApplication)} {nameof(Setup)} {LocalEndPoint}"); 41 | } 42 | 43 | public override void TearDown() 44 | { 45 | Console.WriteLine($"{nameof(TestApplication)} {nameof(TearDown)}"); 46 | } 47 | 48 | 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /KcpServer/TestServer/TestPeer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using KcpServer; 7 | using static Utilities.MakeTestBuff; 8 | namespace TestServer 9 | { 10 | class TestUdpPeer : KcpServer.PeerBase 11 | { 12 | public TestUdpPeer(PeerContext pc) : base(pc) 13 | { 14 | Console.WriteLine($"{nameof(TestUdpPeer)} sid:{pc.SessionId} created"); 15 | } 16 | 17 | public override void OnOperationRequest(byte[] data) 18 | { 19 | var i = BitConverter.ToInt64(data, 0); 20 | var snd = i + 1; 21 | this.SendOperationResponse(BitConverter.GetBytes(snd)); 22 | Console.WriteLine($"sid:{this.SessionId}->rec:{i} snd:{snd}"); 23 | } 24 | } 25 | class TestUdpPeer2 : KcpServer.PeerBase 26 | { 27 | public TestUdpPeer2(PeerContext pc) : base(pc) 28 | { 29 | Console.WriteLine($"{nameof(TestUdpPeer2)} sid:{pc.SessionId} created"); 30 | } 31 | 32 | public override void OnOperationRequest(byte[] data) 33 | { 34 | this.SendOperationResponse(data); 35 | } 36 | } 37 | 38 | public class BigBuffPeer : KcpServer.KcpPeerBase 39 | { 40 | public BigBuffPeer(PeerContext pc) : base(pc) 41 | { 42 | Console.WriteLine($"{nameof(BigBuffPeer)} sid:{pc.SessionId} created"); 43 | } 44 | 45 | public override void OnOperationRequest(byte[] data) 46 | { 47 | if (data.Length > sizeof(UInt64)) 48 | { 49 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(data)} size:{data.Length}"); 50 | } 51 | 52 | //send back to client 53 | SendOperationResponse(data); 54 | } 55 | } 56 | 57 | public class BigBuffPeerFlush : KcpServer.KcpPeerBase 58 | { 59 | public BigBuffPeerFlush(PeerContext pc) : base(pc) 60 | { 61 | Console.WriteLine($"{nameof(BigBuffPeerFlush)} sid:{pc.SessionId} created"); 62 | } 63 | 64 | public override void OnOperationRequest(byte[] data) 65 | { 66 | if (data.Length > sizeof(UInt64)) 67 | { 68 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(data)} size:{data.Length}"); 69 | } 70 | 71 | //send back to client 72 | SendOperationResponse(data); 73 | KcpFlush(); 74 | } 75 | } 76 | 77 | public class ExPeer : KcpPeerEx 78 | { 79 | public ExPeer(PeerContext pc) : base(pc) 80 | { 81 | Console.WriteLine($"{nameof(ExPeer)} sid:{pc.SessionId} created"); 82 | } 83 | 84 | public override void OnOperationRequest(byte[] data) 85 | { 86 | //貌似这里不知道是不是非可靠消息传递过来的,没有暴露到接口层面。不过貌似意义不大,反正收到了指令,在乎这个指令是怎么来的吗? 87 | if (data.Length == sizeof(UInt64)) 88 | { 89 | var i = BitConverter.ToInt64(data, 0); 90 | var snd = i + 1; 91 | this.SendOperationResponse(BitConverter.GetBytes(snd), true); 92 | Console.WriteLine($"sid:{this.SessionId}->rec:{i} snd:{snd}"); 93 | } 94 | else 95 | { 96 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(data)} size:{data.Length}"); 97 | //send back to client 98 | SendOperationResponse(data); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /KcpServer/TestServer/TestServer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3C634EE3-7558-4393-91F7-CB34DE76A5E9} 8 | Exe 9 | TestServer 10 | TestServer 11 | v4.6.2 12 | 512 13 | true 14 | 15 | 16 | x64 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Form 55 | 56 | 57 | ServerForm1.cs 58 | 59 | 60 | 61 | 62 | 63 | 64 | ServerForm1.cs 65 | 66 | 67 | ResXFileCodeGenerator 68 | Resources.Designer.cs 69 | Designer 70 | 71 | 72 | True 73 | Resources.resx 74 | 75 | 76 | SettingsSingleFileGenerator 77 | Settings.Designer.cs 78 | 79 | 80 | True 81 | Settings.settings 82 | True 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | {16278a10-a238-41e5-ac2a-d9316489fa32} 91 | KcpServer 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/Assets/Script/Test.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using UnityEngine.UI; 4 | using System.Runtime.InteropServices; 5 | using k = KcpClient; 6 | using System.Net; 7 | using System.Linq; 8 | using System; 9 | 10 | public class Test : MonoBehaviour 11 | { 12 | public Button ConnetBtn; 13 | public Button CloseBtn; 14 | public Button Send1Btn; 15 | public Button Send2Btn; 16 | public InputField IPPort; 17 | public Text Console; 18 | public Text Title; 19 | 20 | k.KcpClientEx client; 21 | IPEndPoint remoteipep; 22 | 23 | // Use this for initialization 24 | void Start() 25 | { 26 | 27 | ConnetBtn.onClick.AddListener(() => 28 | { 29 | if (client != null) 30 | { 31 | client.Close(); 32 | } 33 | client = new k.KcpClientEx("Test".ToCharArray().Select(a => (byte)a).ToArray(), 0, "mixpeer".ToCharArray().Select(a => (byte)a).ToArray()); 34 | var arr = IPPort.text.Split(":"[0]); 35 | remoteipep = new IPEndPoint(IPAddress.Parse(arr[0]), int.Parse(arr[1])); 36 | client.OnOperationResponse = (buf) => 37 | { 38 | if (buf.Length == sizeof(UInt64)) 39 | { 40 | var i = BitConverter.ToInt64(buf, 0); 41 | //Console.WriteLine($"rec unreliable:{i}"); 42 | Console.text += string.Format("rec unreliable:{0}\n", i); 43 | } 44 | else 45 | { 46 | //Console.WriteLine($"rec reliable {nameof(CheckBigBBuff)}={CheckBigBBuff(buf)} size:{buf.Length} "); 47 | Console.text += string.Format("rec unreliable:{0}={1} size:{2}\n", "CheckBigBBuff", Utilities.MakeTestBuff.CheckBigBBuff(buf), buf.Length); 48 | } 49 | }; 50 | client.OnConnected = (sid) => 51 | { 52 | this.Title.text = sid.ToString(); 53 | }; 54 | 55 | client.Connect(remoteipep, false); 56 | }); 57 | CloseBtn.onClick.AddListener(() => 58 | { 59 | client.Close(); 60 | client = null; 61 | }); 62 | Send1Btn.onClick.AddListener(() => 63 | { 64 | client.SendOperationRequest(Utilities.MakeTestBuff.MakeBigBuff()); 65 | }); 66 | Send2Btn.onClick.AddListener(() => 67 | { 68 | client.SendOperationRequest(BitConverter.GetBytes((UInt64)1), true); 69 | }); 70 | } 71 | 72 | // Update is called once per frame 73 | void Update() 74 | { 75 | if (client != null) 76 | { 77 | client.DoWork(); 78 | client.Service(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/Assets/Script/TestScript.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class TestScript : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | 9 | } 10 | 11 | // Update is called once per frame 12 | void Update () { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/Assets/aaaa.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Assets/aaaa.unity -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/AnnotationManager: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/AnnotationManager -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/AssetImportState: -------------------------------------------------------------------------------- 1 | 5;0;6;-1 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/AssetServerCacheV3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/AssetServerCacheV3 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/AssetVersioning.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/AssetVersioning.db -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/BuildPlayer.prefs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/BuildPlayer.prefs -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/BuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/BuildSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/CurrentLayout.dwlt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/CurrentLayout.dwlt -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/EditorUserBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/EditorUserBuildSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/EditorUserSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/EditorUserSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/InspectorExpandedItems.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/InspectorExpandedItems.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/LastSceneManagerSetup.txt: -------------------------------------------------------------------------------- 1 | sceneSetups: 2 | - path: Assets/aaaa.unity 3 | isLoaded: 1 4 | isActive: 1 5 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/LibraryFormatVersion.txt: -------------------------------------------------------------------------------- 1 | unityRebuildLibraryVersion: 11 2 | unityForwardCompatibleVersion: 40 3 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/MonoManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/MonoManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ProjectSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ScriptAssemblies/Assembly-CSharp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ScriptAssemblies/Assembly-CSharp.dll -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ScriptAssemblies/Assembly-CSharp.dll.mdb -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ScriptAssemblies/BuiltinAssemblies.stamp: -------------------------------------------------------------------------------- 1 | 0000.58087744.0000 2 | 0000.58087766.0000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ScriptMapper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ScriptMapper -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/5/50e978ae2b8aeb852d38754114b5918a.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/5/50e978ae2b8aeb852d38754114b5918a.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/5/56f3b856f7d96adb19b4a9a6f38c4a13.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/5/56f3b856f7d96adb19b4a9a6f38c4a13.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/6/67139f55793d4e2e36244363e4dc999d.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/6/67139f55793d4e2e36244363e4dc999d.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/7/79d4d60e848d5db61d698b53d65a5676.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/7/79d4d60e848d5db61d698b53d65a5676.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/8/8ad788dff8db13e50c06e32bb9c2c452.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/8/8ad788dff8db13e50c06e32bb9c2c452.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/8/8e33aedd948632d631fb31f32ce19593.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/8/8e33aedd948632d631fb31f32ce19593.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/9/9ea2134cde481652e76ca73f8fea90b6.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/9/9ea2134cde481652e76ca73f8fea90b6.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/b/bfbe139b7fe6f9dcc6ddb52a33a7dd8f.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/b/bfbe139b7fe6f9dcc6ddb52a33a7dd8f.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/c/c67b3c7d3c93aade82053b2950c85cde.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/c/c67b3c7d3c93aade82053b2950c85cde.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/ShaderCache/f/f25cfe62e5edcc3e62471f8f427277f8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/ShaderCache/f/f25cfe62e5edcc3e62471f8f427277f8.bin -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/UnityAssemblies/UnityEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/UnityAssemblies/UnityEditor.dll -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/UnityAssemblies/UnityEngine.Networking.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/UnityAssemblies/UnityEngine.Networking.dll -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/UnityAssemblies/UnityEngine.UI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/UnityAssemblies/UnityEngine.UI.dll -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/UnityAssemblies/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/UnityAssemblies/UnityEngine.dll -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/UnityAssemblies/version.txt: -------------------------------------------------------------------------------- 1 | 5.4.2f2:2.8.0.0 2 | StandaloneWindows 3 | D:/Program Files/Unity/Editor/Data/Managed/UnityEngine.dll 4 | D:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll 5 | D:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll 6 | D:/Program Files/Unity/Editor/Data/Managed/UnityEditor.dll -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/assetDatabase3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/assetDatabase3 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/expandedItems: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/expandedItems -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000001000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000001000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000001000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: Assets 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000001000000000000000 12 | path: 13 | localIdentifier: 102900000 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1030 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000002000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000002000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000002000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: InputManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000002000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000003000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000003000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000003000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: TagManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000003000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000004000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000004000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000004000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: ProjectSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000004000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000004100000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000004100000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000004100000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: NavMeshAreas 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000004100000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000005000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000005000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000005000000000000000.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000005000000000000000.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000005100000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000005100000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000005100000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: Physics2DSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000005100000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000006000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000006000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000006000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: AudioManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000006000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000006100000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000006100000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000006100000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: GraphicsSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000006100000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000007000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000007000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000007000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: TimeManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000007000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000007100000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000007100000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000007100000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: ClusterInputManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000007100000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______  -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000008000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000008000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000008000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: DynamicsManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000008000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000008100000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000008100000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000008100000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: UnityAdsSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000008100000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000009000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/00000000000000009000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/00000000000000009000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: QualitySettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 00000000000000009000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000a000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/0000000000000000a000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000a000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: NetworkManager 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 0000000000000000a000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000a100000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/0000000000000000a100000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000a100000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: UnityConnectSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 0000000000000000a100000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ 26 |  -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000b000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/0000000000000000b000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000b000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: EditorBuildSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 0000000000000000b000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______  -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000c000000000000000: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/00/0000000000000000c000000000000000 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/00/0000000000000000c000000000000000.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: EditorSettings 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 0000000000000000c000000000000000 12 | path: 13 | localIdentifier: 5 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1038 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/0d/0d9af4055650a4a4aabd94898e22462a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/0d/0d9af4055650a4a4aabd94898e22462a -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/2d/2dbc27900c48e94458b6cc3f2a9ece09: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/2d/2dbc27900c48e94458b6cc3f2a9ece09 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/34/34a1b6c94ffd2ed4cb00d9fd8a4e7bf0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/34/34a1b6c94ffd2ed4cb00d9fd8a4e7bf0 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/34/34a1b6c94ffd2ed4cb00d9fd8a4e7bf0.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: Plugins 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 34a1b6c94ffd2ed4cb00d9fd8a4e7bf0 12 | path: Assets/Plugins 13 | localIdentifier: 102900000 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1030 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/3c/3c0ad459c1534645b5d603b7cc258f97: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/3c/3c0ad459c1534645b5d603b7cc258f97 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/3c/3c0ad459c1534645b5d603b7cc258f97.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/3c/3c0ad459c1534645b5d603b7cc258f97.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/49/49b0a1b03cd120841b34607dc7762975: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/49/49b0a1b03cd120841b34607dc7762975 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/4a/4a29928001fcb444e8f830b166827fa2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/4a/4a29928001fcb444e8f830b166827fa2 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/4a/4a29928001fcb444e8f830b166827fa2.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: KcpClient 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 4a29928001fcb444e8f830b166827fa2 12 | path: Assets/Plugins/x64/KcpClient.dll 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______) -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/54/545c21c93e5b59b40bc3c9687584ba8e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/54/545c21c93e5b59b40bc3c9687584ba8e -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/54/545c21c93e5b59b40bc3c9687584ba8e.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: kcplib 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 545c21c93e5b59b40bc3c9687584ba8e 12 | path: Assets/Plugins/x64/kcplib.so 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______" -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/5f/5f32cd94baa94578a686d4b9d6b660f7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/5f/5f32cd94baa94578a686d4b9d6b660f7 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/5f/5f32cd94baa94578a686d4b9d6b660f7.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/5f/5f32cd94baa94578a686d4b9d6b660f7.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/73/739bbd9f364b4268874f9fd86ab3beef: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/73/739bbd9f364b4268874f9fd86ab3beef -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/73/739bbd9f364b4268874f9fd86ab3beef.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/73/739bbd9f364b4268874f9fd86ab3beef.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/74/744874c484c2e1344a374081bafdca93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/74/744874c484c2e1344a374081bafdca93 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/74/744874c484c2e1344a374081bafdca93.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: Test 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 744874c484c2e1344a374081bafdca93 12 | path: Assets/Script/Test.cs 13 | localIdentifier: 11500000 14 | thumbnailClassID: 115 15 | flags: 0 16 | scriptClassName: Test 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1035 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/79/7909d14fbd7075848a75e5cc1d04d145: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/79/7909d14fbd7075848a75e5cc1d04d145 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/79/7909d14fbd7075848a75e5cc1d04d145.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: TestScript 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 7909d14fbd7075848a75e5cc1d04d145 12 | path: Assets/Script/TestScript.cs 13 | localIdentifier: 11500000 14 | thumbnailClassID: 115 15 | flags: 0 16 | scriptClassName: TestScript 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1035 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______+ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/7c/7cbab2be89b54486bbd23a6fe637d30e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/7c/7cbab2be89b54486bbd23a6fe637d30e -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/7c/7cbab2be89b54486bbd23a6fe637d30e.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: nunit.framework 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 7cbab2be89b54486bbd23a6fe637d30e 12 | path: 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/80/80a3616ca19596e4da0f10f14d241e9f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/80/80a3616ca19596e4da0f10f14d241e9f -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/80/80a3616ca19596e4da0f10f14d241e9f.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/80/80a3616ca19596e4da0f10f14d241e9f.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/85/852e56802eb941638acbb491814497b0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/85/852e56802eb941638acbb491814497b0 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/85/852e56802eb941638acbb491814497b0.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: UnityEngine.Analytics 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 852e56802eb941638acbb491814497b0 12 | path: 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/86/8662cdb7d9c58da4e871e9cd7253993e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/86/8662cdb7d9c58da4e871e9cd7253993e -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/86/8662cdb7d9c58da4e871e9cd7253993e.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: aaaa 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 8662cdb7d9c58da4e871e9cd7253993e 12 | path: Assets/aaaa.unity 13 | localIdentifier: 102900000 14 | thumbnailClassID: 1032 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1030 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/87/870353891bb340e2b2a9c8707e7419ba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/87/870353891bb340e2b2a9c8707e7419ba -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/87/870353891bb340e2b2a9c8707e7419ba.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/87/870353891bb340e2b2a9c8707e7419ba.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/89/89b17335b6b86fa46ba3cec8ab68e905: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/89/89b17335b6b86fa46ba3cec8ab68e905 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/8e/8e0cd8ed44d4412cbe0642067abc9e44: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/8e/8e0cd8ed44d4412cbe0642067abc9e44 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/8e/8e0cd8ed44d4412cbe0642067abc9e44.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/8e/8e0cd8ed44d4412cbe0642067abc9e44.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/95/951d0179d2661f4498773ccaa0ff9605: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/95/951d0179d2661f4498773ccaa0ff9605 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/95/951d0179d2661f4498773ccaa0ff9605.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: Script 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 951d0179d2661f4498773ccaa0ff9605 12 | path: Assets/Script 13 | localIdentifier: 102900000 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1030 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/97/97decbdab0634cdd991f8d23ddf0dead: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/97/97decbdab0634cdd991f8d23ddf0dead -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/97/97decbdab0634cdd991f8d23ddf0dead.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: UnityEditor.Advertisements 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: 97decbdab0634cdd991f8d23ddf0dead 12 | path: 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/a7/a72c9d1faa3616e4da86af09280a5e13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/a7/a72c9d1faa3616e4da86af09280a5e13 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/a7/a72c9d1faa3616e4da86af09280a5e13.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: x86 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: a72c9d1faa3616e4da86af09280a5e13 12 | path: Assets/Plugins/x86 13 | localIdentifier: 102900000 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1030 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/ad/adebbd281f1a4ef3a30be7f21937e02f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/ad/adebbd281f1a4ef3a30be7f21937e02f -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/ad/adebbd281f1a4ef3a30be7f21937e02f.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/ad/adebbd281f1a4ef3a30be7f21937e02f.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/bc/bc0915f93bc20bb4f90dead66b755481: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/bc/bc0915f93bc20bb4f90dead66b755481 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/d7/d72e8ef70b3ab1e4b829e212338969d6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/d7/d72e8ef70b3ab1e4b829e212338969d6 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/d7/d72e8ef70b3ab1e4b829e212338969d6.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: kcpwarpper 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: d72e8ef70b3ab1e4b829e212338969d6 12 | path: Assets/Plugins/x64/kcpwarpper.dll 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______+ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/ee/eecd871b25c187b4fa1d82d8b2376c56: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/ee/eecd871b25c187b4fa1d82d8b2376c56 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/ee/eecd871b25c187b4fa1d82d8b2376c56.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: kcplib 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: eecd871b25c187b4fa1d82d8b2376c56 12 | path: Assets/Plugins/x64/kcplib.dll 13 | localIdentifier: -1121539586 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1050 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______# -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/f3/f38eedb01e55a424eb25b101fc67ef5b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/f3/f38eedb01e55a424eb25b101fc67ef5b -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/f3/f38eedb01e55a424eb25b101fc67ef5b.info: -------------------------------------------------------------------------------- 1 | PreviewAssetDataBaseName: 2 | mainRepresentation: 3 | name: x64 4 | thumbnail: 5 | m_Format: 0 6 | m_Width: 0 7 | m_Height: 0 8 | m_RowBytes: 0 9 | image data: 0 10 | _typelessdata: 11 | guid: f38eedb01e55a424eb25b101fc67ef5b 12 | path: Assets/Plugins/x64 13 | localIdentifier: 102900000 14 | thumbnailClassID: 1029 15 | flags: 0 16 | scriptClassName: 17 | representations: [] 18 | labels: 19 | m_Labels: [] 20 | assetImporterClassID: 1030 21 | assetBundleFullName: 22 | m_AssetBundleName: 23 | m_AssetBundleVariant: 24 | externalReferencesForValidation: [] 25 | AssetInfo_______ -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/f5/f5f67c52d1564df4a8936ccd202a3bd8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/f5/f5f67c52d1564df4a8936ccd202a3bd8 -------------------------------------------------------------------------------- /KcpServer/TestU3d/Library/metadata/f5/f5f67c52d1564df4a8936ccd202a3bd8.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Library/metadata/f5/f5f67c52d1564df4a8936ccd202a3bd8.info -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.4.2f2 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /KcpServer/TestU3d/Temp/__Backupscenes/0.backup: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a11s/kcp_csserver/4249ec10a7817a1f3124df261224708050559426/KcpServer/TestU3d/Temp/__Backupscenes/0.backup -------------------------------------------------------------------------------- /KcpServer/TestU3d/Test.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2015 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test.csproj", "{79442293-7E96-307B-F9DE-2D63F40DDE1B}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {79442293-7E96-307B-F9DE-2D63F40DDE1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {79442293-7E96-307B-F9DE-2D63F40DDE1B}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {79442293-7E96-307B-F9DE-2D63F40DDE1B}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {79442293-7E96-307B-F9DE-2D63F40DDE1B}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KcpServer/TestU3d/TestU3d.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2015 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestU3d", "TestU3d.csproj", "{AF53ECFF-7647-23C1-7BA5-36DE448752C9}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {AF53ECFF-7647-23C1-7BA5-36DE448752C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {AF53ECFF-7647-23C1-7BA5-36DE448752C9}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {AF53ECFF-7647-23C1-7BA5-36DE448752C9}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {AF53ECFF-7647-23C1-7BA5-36DE448752C9}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KcpServer/Utilities/Fiber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading; 6 | //using System.Threading.Tasks; 7 | 8 | namespace Utilities 9 | { 10 | public class ThreadPoolFiber : IFiber 11 | { 12 | public int fiberid = -1; 13 | FiberPool fp = null; 14 | internal void AttachFiberPool(FiberPool fp) 15 | { 16 | this.fp = fp; 17 | } 18 | 19 | public ThreadPoolFiber(FiberPool fp, int fiberidSeed) 20 | { 21 | AttachFiberPool(fp); 22 | this.fiberid = Math.Abs(fiberidSeed) % fp.GetWorkerCount; 23 | } 24 | //ConcurrentQueue _works = new ConcurrentQueue(); 25 | public void Enqueue(Action t) 26 | { 27 | fp.Enqueue(fiberid, t); 28 | } 29 | 30 | public const int WS_FREE = 0; 31 | public const int WS_WORKING = 10; 32 | public const int WS_BUSY = 1000; 33 | public const int WS_DOS = 1000; 34 | 35 | public WorkingState State 36 | { 37 | get 38 | { 39 | var cnt = fp.GetWorkingQueueLength(this.fiberid); 40 | if (cnt <= WS_FREE) 41 | { 42 | return WorkingState.Free; 43 | } 44 | if (cnt <= WS_WORKING) 45 | { 46 | return WorkingState.Working; 47 | } 48 | if (cnt <= WS_BUSY) 49 | { 50 | return WorkingState.Busy; 51 | } 52 | else 53 | { 54 | return WorkingState.DenialOfService; 55 | } 56 | } 57 | } 58 | } 59 | /// 60 | /// 单线程,所以没有用并行库 61 | /// 62 | public class Fiber : IFiber 63 | { 64 | public const int WS_FREE = 0; 65 | public const int WS_WORKING = 10; 66 | public const int WS_BUSY = 1000; 67 | public const int WS_DOS = 1000; 68 | public Queue works = new Queue(); 69 | public WorkingState State 70 | { 71 | get 72 | { 73 | var cnt = works.Count; 74 | if (cnt <= WS_FREE) 75 | { 76 | return WorkingState.Free; 77 | } 78 | if (cnt <= WS_WORKING) 79 | { 80 | return WorkingState.Working; 81 | } 82 | if (cnt <= WS_BUSY) 83 | { 84 | return WorkingState.Busy; 85 | } 86 | else 87 | { 88 | return WorkingState.DenialOfService; 89 | } 90 | } 91 | } 92 | 93 | public void Enqueue(Action t) 94 | { 95 | works.Enqueue(t); 96 | } 97 | } 98 | 99 | public enum WorkingState 100 | { 101 | Free = 0, 102 | Working = 1, 103 | Busy = 2, 104 | 105 | DenialOfService = 3, 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /KcpServer/Utilities/FiberPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Threading; 4 | using System.Linq; 5 | namespace Utilities 6 | { 7 | public class FiberPool 8 | { 9 | Thread[] threads = null; 10 | ConcurrentQueue[] works; 11 | bool[] threadCloseState; 12 | public int GetWorkerCount => threads.Length; 13 | /// 14 | /// 执行中 15 | /// 16 | bool Running = true; 17 | /// 18 | /// 不再接受更多任务 19 | /// 20 | bool Closing = false; 21 | public Action DebugLog = (string s) => 22 | { 23 | #if DEBUG 24 | Console.WriteLine(s); 25 | #endif 26 | }; 27 | 28 | public FiberPool(int cnt) 29 | { 30 | works = new ConcurrentQueue[cnt]; 31 | threadCloseState = new bool[cnt]; 32 | for (int i = 0; i < works.Length; i++) works[i] = new ConcurrentQueue(); 33 | threads = new Thread[cnt]; 34 | for (int i = 0; i < threads.Length; i++) 35 | { 36 | threads[i] = new Thread(DoWork); 37 | var t = threads[i]; 38 | t.IsBackground = true; 39 | t.Name = $"fp_worker_{i}"; 40 | t.Start(i); 41 | threadCloseState[i] = false; 42 | } 43 | DebugLog($"{nameof(FiberPool)} started"); 44 | } 45 | 46 | 47 | 48 | internal int GetWorkingQueueLength(int fiberid) 49 | { 50 | return works[fiberid].Count; 51 | } 52 | 53 | private void DoWork(object arg) 54 | { 55 | var i = (int)arg; 56 | var w = works[i]; 57 | SpinWait sw = new SpinWait(); 58 | while (Running) 59 | { 60 | while (Running && w.TryDequeue(out var a)) 61 | { 62 | a();//todo 出错以后是忽略还是崩溃应当有配置:RESTART IGNORE NONE 63 | } 64 | if (Closing) 65 | { 66 | threadCloseState[i] = true; 67 | DebugLog($"{nameof(FiberPool)} thread {i} exit"); 68 | break; 69 | } 70 | sw.SpinOnce(); 71 | } 72 | } 73 | public void SyncClose(TimeSpan timeout) 74 | { 75 | Closing = true; 76 | DebugLog($"{nameof(FiberPool)} Closing"); 77 | SpinWait sw = new SpinWait(); 78 | DateTime starttime = DateTime.Now; 79 | while (true) 80 | { 81 | var closed = threadCloseState.Count(a => a); 82 | if (closed == threadCloseState.Length) 83 | { 84 | //all closed 85 | DebugLog($"{nameof(FiberPool)} All thread closed"); 86 | Running = false; 87 | break; 88 | } 89 | if (DateTime.Now.Subtract(starttime) > timeout) 90 | { 91 | Running = false; 92 | DebugLog($"{nameof(FiberPool)} Close time out"); 93 | break; 94 | } 95 | else 96 | { 97 | sw.SpinOnce(); 98 | } 99 | 100 | } 101 | } 102 | /// 103 | /// 把任务堆到线程的工作队列 104 | /// 105 | /// 106 | /// 107 | public void Enqueue(int id, Action a) 108 | { 109 | if (Closing) 110 | { 111 | throw new InvalidOperationException("不要在关闭的时候继续堆任务"); 112 | } 113 | var tid = id % threads.Length; 114 | works[tid].Enqueue(a); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /KcpServer/Utilities/IFiber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Utilities 4 | { 5 | public interface IFiber 6 | { 7 | WorkingState State { get; } 8 | 9 | void Enqueue(Action t); 10 | } 11 | } -------------------------------------------------------------------------------- /KcpServer/Utilities/MakeTestBuff.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Utilities 6 | { 7 | public static class MakeTestBuff 8 | { 9 | //every pack 1000, split 128 packs, without header and resent,it should be less than 120 10 | const int BUFFSIZE = 120*1000; 11 | public static byte[] MakeBigBuff() 12 | { 13 | byte[] buff = new byte[BUFFSIZE]; 14 | for (int i = 0; i < buff.Length; i++) 15 | { 16 | buff[i] = (byte)i; 17 | } 18 | return buff; 19 | } 20 | 21 | public static bool CheckBigBBuff(byte[] buff) 22 | { 23 | if (buff.Length != BUFFSIZE) 24 | { 25 | return false; 26 | } 27 | for (int i = 0; i < buff.Length; i++) 28 | { 29 | if (buff[i] != (byte)i) return false; 30 | } 31 | 32 | return true; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /KcpServer/Utilities/PPack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | //using System.Threading.Tasks; 6 | 7 | 8 | namespace Utilities 9 | { 10 | public enum ClientErrorCode 11 | { 12 | BAD_SYSID = -1, 13 | APP_REFUSED = -2, 14 | APP_REFUSED2 = -3, 15 | SERVER_REFUSED = -10, 16 | SERVER_TIMEOUT = -11, 17 | } 18 | 19 | public class PackSettings 20 | { 21 | public const int MAX_DATA_LEN = 1000; 22 | public const int HEADER_LEN = 12; 23 | public const int MAX_RECBUFF_LEN = 1024 * 1024 * 2;//2MB 24 | } 25 | 26 | public enum PackType 27 | { 28 | Udp = 0, 29 | Kcp = 1, 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /KcpServer/Utilities/Utilities.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 46ad2778-1c68-459f-8578-8739ada49b2b 7 | 8 | 9 | Utilities 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /KcpServer/Utilities/Utilities.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 46ad2778-1c68-459f-8578-8739ada49b2b 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 要科学 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kcp_csserver # 2 | 3 | 用kcp_warpper跟dotnetty的lib做一个简单的kcpserver.   4 | ## 目前已经完成:   5 | 1 dotnetty 的udp服务器 6 | 2 session管理 7 | 3 集成了kcp用于可靠传输 8 | 4 客户端lib 9 | 5 单线程的Server版本.(某些场景不允许开线程) 10 | 7 支持dotnet core 2.0 Ubuntu下测试通过   11 | 8 提供了可靠数据包跟不可靠数据包两种传输方式 12 | 9 整理了测试项目,阅读起来更方便了 13 | 10 unity3d用的Client版本可以用了,安卓x64环境下测试通过 14 | 11 新的测试4,大约每秒2W左右.用的WinForm的Timer,防止跨线程问题. 15 | ## 计划内的尚未完成的工作   16 | 更多的测试代码   17 | 性能测试以及优化一些无用的new和copy 18 | 19 | ### 用法 服务器端 20 | 21 | 22 | public static void StartServer(IPEndPoint ipep) 23 | { 24 | Server = new KcpServer.Lite.KcpServerLite(); 25 | App = new TestApplicationLite(); 26 | var sysid = "Test".ToCharArray().Select(a => (byte)a).ToArray(); 27 | var appid = "App1".ToCharArray().Select(a => (byte)a).ToArray(); 28 | var sc = KcpServer.Lite.ServerConfig.Create() 29 | .SetSysId(sysid) 30 | .SetApplicationData(appid) 31 | .BindApplication(Program.App) 32 | .SetTimeout(TimeSpan.FromSeconds(10)) 33 | //.SetFiberPool(new Utilities.FiberPool(8)) 34 | .SetLocalIpep(ipep) 35 | .SetMaxPlayer(8) 36 | ; 37 | Server.Start(sc); 38 | } 39 | 40 | 41 | 42 |         43 | ### 用法 客户端 44 | 45 | 46 | private void button_init_Click(object sender, EventArgs e) 47 | { 48 | if (client != null) 49 | { 50 | client.Close(); 51 | } 52 | client = new k.KcpClient("Test".ToCharArray().Select(a => (byte)a).ToArray(), 0, "kcppeer".ToCharArray().Select(a => (byte)a).ToArray()); 53 | var arr = textBox_remote.Text.Split(":"[0]); 54 | remoteipep = new IPEndPoint(IPAddress.Parse(arr[0]), int.Parse(arr[1])); 55 | client.OnOperationResponse = (buf) => 56 | { 57 | Console.WriteLine($"{nameof(CheckBigBBuff)}={CheckBigBBuff(buf)} size:{buf.Length} "); 58 | }; 59 | client.OnConnected = (sid) => 60 | { 61 | this.Invoke( 62 | new Action(() => 63 | { 64 | this.Text = sid.ToString(); 65 | }) 66 | ); 67 | 68 | }; 69 | client.Connect(remoteipep); 70 | } 71 | 72 | ## 注意事项 73 | 1 如果真的需要即时的发出数据,那么需要使用client的flush方法.否则你总会有那么一个小延迟 74 | 2 kcp方法调用是不支持多线程的,如果你使用了flush,那么请不要用后台线程去DoWork().否则不安全. 75 | 3 即便你都是单线程的,也不能无脑的while true去发,这样会把缓冲区爆掉.需要在恰当的时机去看一下waitsnd的值.毕竟带宽不是无限的. 76 | 4 开一个客户端的时候,你的pingpong测试数据可能只有32qps 或者64qps.原因是这种测试正好命中了最糟糕的情况.因为消息的执行并不是收到后立刻执行的,在服务器收到数据以后,先堆积到线程池,每个worker在没有任务的时候会有一个短暂的SpinOnce(),于是这种测试正好全部命中SpinOnce(),这里如果觉得每个用户32qps不够用,就需要修改任务调度这部分. 77 | 5 一定要熟悉kcp的参数设置.要理解每个参数的意义. 78 | 79 | ## 测试图 80 |   81 | 82 |   83 | 84 | --------------------------------------------------------------------------------