[erlang-questions] COWBOY loop handler issue

Roger Lipscombe roger@REDACTED
Thu Sep 14 13:36:10 CEST 2017


On 14 September 2017 at 09:22, Mohammed mazhar uddin
<mohammedmazharuddin@REDACTED> wrote:
> Hello,
>
>     I am new to cowboy and i am trying to create a web application but here
> i am having a issue with loop handler or say server sent events,
>
>         my requirement is that i need to send a message to my loop handler
> from another module which in terms will send the message to clients and
> buttons will be rendered on the web page.
>
> my questions are
>
> 1)How can i send message to my loop handler from another module?

You need to be able to find the loop handler pid from somewhere else.
That usually means some sort of process registry. Once you've got the
Pid, just Pid ! Event.

See http://blog.differentpla.net/blog/2014/11/07/erlang-sup-event#give-me-an-example,
for an example. That covers Erlang supervised event handlers as well
(which is out of scope for what you're asking), but it does
demonstrate using a cowboy loop handler for server-sent events.

> 2)Which process exactly spawns my loop handler.

Doesn't matter.

> 3)Why my loop handler is dying and executing again and again after a
> specific span of time when a client is in communication with server.

Timeouts? Impossible to say.

>                 please reply in the earliest.

This is a mailing list, not a paid support channel.



More information about the erlang-questions mailing list