KNet is simple, lightweight and extensible TCP/IP server framework. It uses two third party libraries (UMemory and DILibrary) and EntityFramework as ORM. UMemory is unsafe context C# .NET 4.6 library used for reading and writing buffers to avoid some unnecessary calls from .NET GC. It has custom length format for arrays and strings. DILibrary is just lightweight dependency injection library.
First build and publish KNetDatabase onto MSSQL database engine instance. Then execute all scripts in KNetDatabase/Data/KNet.
After database is successfully set up, build KNetFramework. If release build configuration is selected, in bin/Release should be all the required .dll files and configuration file in Config folder. Create new project (console or whatever) and add reference of previously built KNetFramework .dll files. To start server create instance of KNetServer type and call Start() method. Make sure new thread is created if application doesn't serve only as server because it will block thread. Also make sure that KNetConfig file is in folder where application is executed and is correctly configured.
Now, after server is successfully configured, the only thing left is to extend it. There are two main attributes (CommandAttribute And OpcodeAttribute) CommandAttribute is used for adding new commands to server. Commands are invoked via CommandManager InvokeCommand method. All commands must derive from CommandHandlerBase and are stored in database on AssemblyManager initialization. OpcodeAttribute is used for executing network packets. Packets are distinct by OpcodeAttribute Opcode property. When packet arrives, method attribute with same opcode as in packet header is executed. It is important to know packet structure. Note that all packets and commands can be loaded from other assemblies. Framework will load all assemblies from folder whose path is in configuration file under key "assemblypath" and create packet methods and commands that are in assemblies. Note that all assemblies must also have above attributes added in AssemblyInfo.
- Compression
- Cryptography
- UDP support
- Overhaul logging
- Optimization... Optimization... Optimization...
- Initial idea - Arctium Emulation WoW Core
- Signaler.cs - Building Async Coordination Primitives, Part 5: AsyncSemaphore
- Network related stuff - C# SocketAsyncEventArgs High Performance Socket Code
- Packet handling - Arctium Emulation WoW Core (Earlier version)
- Commands handling - TrinityCore
- Entity Framework - Ivan
- Dependency Injection - MSCommunity
Special thanks to Arctium Emulation WoW Core repository. It was big help in beginning and a lot of earlier code was based on that repository. Some similarities are still visible.
Product is licensed by The MIT License (MIT). See LICENSE for more details.