RevenantX / LiteNetLib

Lite reliable UDP library for Mono and .NET
https://revenantx.github.io/LiteNetLib/index.html
MIT License
3k stars 489 forks source link

How to listen client per task. #550

Closed vanhaodev closed 1 month ago

vanhaodev commented 1 month ago

I want to create a while loop in async method for every client. But i see this lib only for single while loop to listen of all client request. Thanks

RevenantX commented 1 month ago

Client per task is more like TCP default mechanism where you will need sync all data between peers. Also this is additional context switches which is slow.

One "super feature" of UDP is that you can process 1000 clients in one "task"/thread. 1000 threads for 1000 clients - will be slower.

What do you want to achieve?

vanhaodev commented 1 month ago

Owner I don't use threads, just use async so that client requests don't have to wait for each other. Still the same thread but not waiting for each other. Some computational tasks may take time and other clients must wait. Is it possible for Litenetlib to write that, if so please guide me

RevenantX commented 1 month ago

Owner I don't use threads, just use async so that client requests don't have to wait for each other. Still the same thread but not waiting for each other. Some computational tasks may take time and other clients must wait. Is it possible for Litenetlib to write that, if so please guide me

async is syntax sugar over threadpool. So they basically threads.

vanhaodev commented 1 month ago

Owner I don't use threads, just use async so that client requests don't have to wait for each other. Still the same thread but not waiting for each other. Some computational tasks may take time and other clients must wait. Is it possible for Litenetlib to write that, if so please guide me

async is syntax sugar over threadpool. So they basically threads.

if litenetlib have any way to handle it, pls help me. Thanks

RevenantX commented 1 month ago

@vanhaodev it doesn't. This is different approach that need much different architecture

vanhaodev commented 1 month ago

@vanhaodev it doesn't. This is different approach that need much different architecture

Can I write a mmorpg realtime server with this lib? Clients do not wait for each other's task.

RevenantX commented 1 month ago

@vanhaodev you need to learn MMORPG server architectures of released games. They will not wait for each other's task. If you really have long tasks (like request from DB) you should move them to async/thread. But all other game logic should be in one thread. This is very hard theme and out of scope of this library support