Giter VIP home page Giter VIP logo

Comments (4)

jhmckimm avatar jhmckimm commented on May 22, 2024

This uses async sockets. Any events triggered will be executed asynchronously, so you'll need to handle this in your application.

from netcoreserver.

vgrudenic avatar vgrudenic commented on May 22, 2024

@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.

volundmush avatar volundmush commented on May 22, 2024

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.

blakepell avatar blakepell commented on May 22, 2024

@volundmush

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.