Skip to content

Kahath/KNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KNet

Join Discord Build status

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.


Getting started

Requirements

Setting up Database

First build and publish KNetDatabase onto MSSQL database engine instance. Then execute all scripts in KNetDatabase/Data/KNet.

Setting up server

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.

Extend it

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.



Ideas, references and influences

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.


License

Product is licensed by The MIT License (MIT). See LICENSE for more details.

About

TCP/IP server framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages