Duh, you are right.
However, if the event handler includes async calls then something like this
code would make sense. Imagine the work being done in response to the
event isn't finished until a callback. "Spamming" the event containing the
async call would be a big problem but the following would fix it.
handlingEvent = no
emitter.on 'event',
if handlingEvent then return
handlingEvent = yes
blah.blah.blah()
setTimeout ->
blah.blah.blah()
handlingEvent = no
On Sun, Jan 26, 2014 at 1:32 PM, Pedro <[email protected]> wrote:
> Unless it's asynchronous, handlingEvent will always be no, JS is
> single-threaded.
>
> On Sunday, 26 de January de 2014 at 21:07, Mark Hahn wrote:
>
> Debugging code is your best prevention.
>
> Otherwise you can do something like ...
>
> handlingEvent = no
>
> emitter.on 'event', ->
> if handlingEvent then return
>
> handlingEvent = yes
>
> blah.blah.blah()
>
> handlingEvent = no
>
>
>
> On Sun, Jan 26, 2014 at 11:38 AM, FirstName LastName <[email protected]
> > wrote:
>
> Is there any way to prevent spam requests like such:
>
> while(true){
> client.emit('event', 'urbeingflooded');
> }
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.