How is pushstream done / Curious Post

General discussion about RuneAudio. Do not post any support or feature requests here.

How is pushstream done / Curious Post

Postby irishwill2008 » 26 Jul 2017, 11:09

I am a developer myself and still learning everything but i notice RuneAudio uses pushstream to grab responses to then update the GUI / Interface accordingly.

I looked online and cant seem to get anything that makes much sense!

Regarding some code:
Code: Select all
var pushstream = new PushStream({
        host: window.location.hostname,
        port: window.location.port,
        modes: GUI.mode,
        reconnectOnChannelUnavailableInterval: 5000
    pushstream.onmessage = renderUI;

What is sending the data to this function? I understand the whole onmessage part but where and what is making it possible to send that information? I couldnt find a lead on it. If i was to make my own pushstream function, how would i go about it? I know its to do with nginx and some configurations but my main confusion is where the data is being sent from so the function can do its thing.

I understand the GUI browser DB (I call it), seems to obtain its values on its first load (and continued from then on) from these pushstreams?

If anyone or the DEVS themselves can explain that would be awesome! I would love to learn how its done so i can use it in future projects as it seems very useful!


Posts: 157
Joined: 26 Jul 2016, 14:49
Location: Ireland

Re: How is pushstream done / Curious Post

Postby hondagx35 » 26 Jul 2017, 20:01

Hi Will,

the data comes from here.
We have multiple channels (queue, playback, library, notify, wlans and nics).

User avatar
Posts: 3039
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: How is pushstream done / Curious Post

Postby rern » 28 Jul 2017, 07:37

Basic Usage


- RuneUI already setup
- Other system - setup pushstream support in /etc/nginx/nginx/.conf

Client - JavaScript
Code: Select all
// need 'pushstream.js'
var pushstream0 = new PushStream( {
   host: window.location.hostname,
   port: window.location.port,
   modes: GUI.mode
} );

// new channel 'channel0'
pushstream0.addChannel( 'channel0' );

// on receive from 'pushstream0' broadcast
pushstream0.onmessage = function( data ) {
   // 'data' is array - 'json' is in data[ 0 ]
   alert( data[ 0 ].msg ); // 'message'

// subscribe 'pushstream0'


Code: Select all
# need 'requests' pip package
import requests 'http://localhost/pub?id=channel0', json={ 'msg': 'message' } )

Code: Select all
$ch = curl_init( 'http://localhost/pub?id=channel0' );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( array( 'msg' => 'message' ) ) );
curl_exec( $ch );
curl_close( $ch );

// or
exec( '/usr/bin/curl -s -v -X POST "http://localhost/pub?id=channel0" -d "{ \"msg\": \"message\" }"' );

Code: Select all
curl -s -v -X POST 'http://localhost/pub?id=channel0' -d '{ "msg": "message" }'

# test with RuneAudio channel 'notify'
curl -s -v -X POST 'http://localhost/pub?id=notify' -d '{ "title": "title", "text": "text" }'
Last edited by rern on 28 Nov 2018, 11:38, edited 4 times in total.
Raspberry Pi 3B > SMSL M8 DAC
Raspberry Pi Zero W
Raspberry Pi 4B
User avatar
Posts: 603
Joined: 14 Jul 2016, 08:15

Re: How is pushstream done / Curious Post

Postby irishwill2008 » 01 Aug 2017, 09:09

Hi guys!

Thanks Frank & Rern. Very useful to know this in my opinion and the information both provided are great! Especially Rern...

Hopefully someone else who is curious this can help :)
Posts: 157
Joined: 26 Jul 2016, 14:49
Location: Ireland

support RuneAudio Donate with PayPal

Return to General discussion

Who is online

Users browsing this forum: No registered users and 0 guests