Memeo/enet-js — Issue #1: Adding an 'empty' event
Author: vampirefrog
Created: 2011-10-12 20:43:29+00:00
State: open

Can you add an event that is triggered whenever there are no more messages/packets in the queue? This way one can make a server in such a way that it takes all input packets, processes them, and then sends out replies, instead of sending replies after each packet.

As an example, here is the sauerbraten enet loop:
http://sauerbraten.svn.sourceforge.net/viewvc/sauerbraten/src/engine/server.cpp?revision=3737&view=markup#l673

It takes enet events, including connect and disconnect, and after it has determined there is nothing more on the pipe (or perhaps there is a 5 ms timeout instead? The timeout parameter is 5 in the file above. I don't know). This type of loop is different than the loop in enet.js. However, I think adding an 'empty' event or whatever you want to name it should suffice for making a cube2 server type loop.