LiteNetLib icon indicating copy to clipboard operation
LiteNetLib copied to clipboard

How to listen client per task.

Open vanhaodev opened this issue 1 year ago • 1 comments

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

vanhaodev avatar May 08 '24 10:05 vanhaodev

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?

RevenantX avatar May 10 '24 08:05 RevenantX

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

vanhaodev avatar May 15 '24 00:05 vanhaodev

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.

RevenantX avatar May 15 '24 07:05 RevenantX

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

vanhaodev avatar May 15 '24 09:05 vanhaodev

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

RevenantX avatar May 15 '24 09:05 RevenantX

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

vanhaodev avatar May 15 '24 09:05 vanhaodev

@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

RevenantX avatar May 15 '24 18:05 RevenantX