Comments (4)
This uses async sockets. Any events triggered will be executed asynchronously, so you'll need to handle this in your application.
from netcoreserver.
@volundmush With async tasks, code either gets executed on a free ThreadPool
thread, or on the thread captured by the context (in case you are doing UI stuff and need to dispatch the results back on the one-and-only UI thread). I/O work also runs on dedicated OS threads, which is supported throughout the OS with IOCP . The main idea is to keep the number of threads low (e.g. tied to the number of cores) and dispatch tasks around them without additional allocations and without too much chattiness between cores.
This article sums it up for .NET tasks, although it goes all the way to the CPU interrupts to explain how the whole process works.
from netcoreserver.
Thanks. Did some research after getting this info. Things make far more sense now. It never occurred to me that C# worked like this.
from netcoreserver.
A little late but I assume since muds/mushes are a hobby you might still be interested. A mud/mush server is what I'm using this for (thought I would share what's worked for me in case it helps anyone later). A mud/mush needs to process things in an ordered fashion (usually). What I did to make that happen was once a command came in asynchronously I added it to a ConcurrentQueue
that held the command and the session it came from. All sends go into a buffer instead of to the socket and THEN the game loop will write the buffer out with netcoreserver. Process in the game loop is:
1.) Dequeue and execute the commands (the queue making it FIFO or the order in which they came in).
2.) Determine what game processing occurs (a Tick, battle messages, game motion stuff, mob updates, etc.)
3.) Send the buffered output to the sessions (basically everything that happened in 1 and 2).
4.) Rinse, repeat.
Generally with a MUD/MUSH/MOO you're not going to run into issues with backpressure.
The async nature of netcoreserver fixes one of the core issues with most C based muds and that is that the commands get queued up as they come. With most C code bases the sockets are looped over from a linked list (in the order they are in the list) and as a result a command that should have been run earlier might get run later (so players who stay on the server longer end up in a better position in the list which is important if you're processing combat commands and want to be at the top of a combat pulse). Few C code bases I've seen randomize their linked lists (because it's a pain and most people run the servers as a hobby on spare time).
from netcoreserver.
Related Issues (20)
- Hello, can you package NetCoreServer Project as a Nuget package HOT 1
- how to get a list of sessions HOT 2
- how can I set the waiting for the package?? HOT 1
- Client unresponsive after server crashes
- websoket server System.IndexOutOfRangeException HOT 1
- How to Choose an Ethernet Adapter HOT 3
- OnDisconneting after send data HOT 1
- IndexOutOfRangeException in WebSocket Server HOT 1
- Cross threading problem reporting tcpSession data to UI HOT 4
- PlayStation 3 Client - SSL connection impossible with HTTPS protocol.
- OnDisconnected without OnConnected? HOT 2
- use wssclient for binance websocket will disconnect when sending ping package
- Question on SSLContext usage
- Performance of UDP echo server
- Why the cache is not updated? HOT 7
- Add cache to the parent directory of index.html in InsertPathInternal? HOT 2
- Fix Bug: .NetFramework 4.8 ClientWebSocket Cann't Connect To .Net8 WsSession HOT 1
- Unhandled exception in WebSocket HOT 12
- Serialize and Deserialze HOT 3
- SimpleW : a RestAPI above NetCoreServer [not an issue but a library using NetCoreServer] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netcoreserver.