COWBOY loop handler issue

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

COWBOY loop handler issue

Mohammed mazhar uddin
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?

2)Which process exactly spawns my loop handler.

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.


The big picture of my requirement.

       -I have a Terminal and few network elements, the moment those
elements boots up they send a registration request to my erlang module
from where i have to send a message to my loop handler to render those
elements in the form of buttons in my web application.

       -Here i cant even register my loop handler as every time a new
request comes, a new process is being created.

            how do i overcome this issue?

                 please reply in the earliest.

                     Thanks in advance.


Regards,

Mazhar.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: COWBOY loop handler issue

Roger Lipscombe-2
On 14 September 2017 at 09:22, Mohammed mazhar uddin
<[hidden email]> 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.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions