Question: Trigger Cumulus functions from PHP/Terminal

78 views
Skip to first unread message

Frank Wayong

unread,
Mar 28, 2014, 6:20:19 AM3/28/14
to openrtmf...@googlegroups.com
Hi,

Is it possible to trigger some functions from the webserver on the same Ubuntu server?

Scenario: An admin will trigger an event which will start the event on all mobile devices who are online at that moment?
=================================================
function startTheEvent()

         for key, cur_client in cumulus.clients:pairs() do

                  cur_client.writer.writeAMFMessage("game_event_A","start")

        end
end
=================================================
Would it be possible that via php (or even ubuntu command line) the cumulus function gets fired?
something like:

<?php
    shell_exec('./CumulusServer >> startTheEvent');
?>

Mathieu Poux

unread,
Mar 31, 2014, 2:59:23 PM3/31/14
to openrtmf...@googlegroups.com
Hi,

Not by this way, sorry, communication inter-process by standard input and output is not crossplatform especially since that Cumulus can be started like a daemon or Windows service.
On webserver side (PHP code), open a TCP client for example, and on Cumulus script side a TCP server like that:
    server = cumulus:createTCPServer()
    function server:clientHandler(client)
        function client:onReception(data)
            NOTE("Reception from "..self.peerAddress.." to "..self.address)
            self:send(data) -- echo sample
            return 0 -- return rest (all has been consumed here)
        end
        function client:onDisconnection()
            NOTE("TCP client disconnection")
        end
    end
    server:start(1234); -- start the server on the port 1234
Or the opposite :-)

Frank Wayong

unread,
Mar 31, 2014, 4:01:42 PM3/31/14
to openrtmf...@googlegroups.com
Hi and big thanks for the info!

This solves some issues for me :)
I already had a feeling that a socket was for that purpose. Now you've shown me how! I am gratefull for you giving me this insight!

Grtz Frank Wayong
--
Vous recevez ce message, car vous êtes abonné à un sujet dans le groupe Google Groupes "OpenRTMFP Cumulus".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/openrtmfp-cumulus/rPr05ftOoG8/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse openrtmfp-cumu...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages