Page 1 of 7
Tornado (webserver with WebSocket)
Posted: Mon Jan 13, 2014 12:34 pm
by Pako
I have a surprise for you.
I created a new plugin. As is evident from the topic title, it's actually a webserver with support WebSocket protocol.
I think something like that, very missed here. I used
Tornado library as a base, and I used the same name for the plugin.
During testing, I have prepared one application that uses some WebSocket actions. So everyone can try!
It is a web interface to control the MusicBee program.
Attached is everything you need. Plugin is packed in zip (including folder).
After unpacking, the whole folder (and its contents) put into the folder
...\EventGhost\plugins.
Please use the latest version of the MusicBee plugin!
Of course you need to set the root of html documents and TCP/IP port in the plugin settings.
In settings of MusicBee plugin you have to adjust the location of the MusicBee program.
I have a good feeling - it works very smoothly.
What is the main:
no more polling !
As usual, when I publish a new plugin, I beg you to perform proofreading.
And of course - I welcome any feedback.
Thanks, Pako
Installation instructions:
A)
Complete instalation (for new users)
A.1) In folder
...\EventGhost\plugins create new folder
Tornado
A.2) Download the file
__init__.py (at the bottom of this post) and move it to new folder
...\EventGhost\plugins\Tornado
A.3) Restart EventGhost and add the plugin
Tornado to your configuration.
B)
Upgrade from version 0.3 or lower to version 0.4 or higher
B.1) In the folder
...\EventGhost\plugins\Tornado there exist a folder
lib. Delete it.
B.2) Download the file
__init__.py and move it to folder
...\EventGhost\plugins\Tornado (replacing the file with the same name).
B.3) Restart EventGhost
C)
Other upgrade
C.1) Download the file
__init__.py and move it to folder
...\EventGhost\plugins\Tornado (replacing the file with the same name).
C.2) Restart EventGhost
Re: Tornado (webserver with WebSocket)
Posted: Mon Jan 13, 2014 1:02 pm
by Pako
This is how it looks on my phone Sony Xperia T.
Using browser:
UC Browser.
Pako
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 6:39 am
by krambriw
Dear Pako, you are again making something very impressive!!!
BR Walter
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 7:35 am
by Pako
krambriw wrote:Dear Pako, you are again making something very impressive!!!
BR Walter
Dear Walter,
I thank you for the compliment.
I hope more people will appreciate it.
It does not appear, but it took many hours to do it.
I have not counted the time, but I estimate it at around 100 hours.
You've already tried it? I expect a more detailed response.
Thanks, Pako
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 8:38 am
by piert
Hi Pako,
First of all, thank you again for a cool contribution.
Unfortunately, I can not yet get it to work.
I installed MusicBee on my laptop.
I downloaded the MusicBee Plugin and made sure the dll is in the plugin folder of MusicBee.
Downloaded the Tornado plugin and the example files (example files are in folder D:\temp\DELETE NOW).
At first try when running the Tornado webserver, I got a blank (white) page showing something like "Tornado is running"(with a running clock), so I thought I was on the right track). However, the MusicBee control page did not show up.
After trying several things in the configurations of the Tornado and MusicBee plugins, I no longer get the blank page, but a coloured page without any of the buttons (I checked the source of the index page, and I see there are a number of buttons that should show on it).
I have made a few screen shots which may make it more clear what is going on:
This is what I see when loading the webserver (index)file (using the 127.0.0.1 URL of the computer itself). Browser is Firefox.
This is what I see when I open the index file in the folder where the index file is located in the browser:
This is the contents of the folder of the index file (i.e. the unzipped example files):
I hope the above makes sense to do some troubleshooting. I really want to get this working!!!
Thanks and best regards,
Perry
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 11:07 am
by Pako
Hi Perry!
I am pleased your interest in the plugin.
1) Use a different browser. For example, Chrome displays the page correctly.
2) When you see the page "It works", it means that you did not specify the name of the HTML document.
In our case, you type the server address (and
:port, if not standard), then you must also add
/index.html .
So in the browser you must enter for example:
http://127.0.0.1:8080/index.html .
Pako
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 2:12 pm
by piert
A reboot did the trick. I now have the correct page, but am a bit stuck as what to do next to make it 'alive'.
I see that when I hit the buttons on the webpage, corresponding commands appear in Eventghost's event log. Obviously, these events can be used to drag to the corresponding commands in MusicBee, which allows control of the player.
But how do I get information from MusicBee into the webpage? I see that, after each song change, an event appears in the Eventghost event log.
For instance:
MusicBee.TrackChanged [u'D:\\muziek\\11 Two Step.MP3', u'\n\n']
Where do I need to drag that Event to in order for making the song name appear on the webpage???
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 2:59 pm
by Pako
And you used the attached file Tornado_Sample_App.xml ?
Pako
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 4:21 pm
by piert
Well I am not sure. I just re-tried and I now got an error regarding loading of the MusicBee Plugin. By default the plugin chooses a different folder than the one where MusicBee is installed. If I change to the correct location in the plugin configuration of MusicBee plugin, I get the following error in the log:

Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 4:31 pm
by Pako
piert wrote:By default the plugin chooses a different folder than the one where MusicBee is installed.
Pako wrote:Of course you need to set the root of html documents and TCP/IP port in the plugin settings.
In settings of MusicBee plugin you have to adjust the location of the MusicBee program.
Ignore the errors, save the document (EventGhost - File - Save)
EventGhost close and re-start it.
It should help.
Pako
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 6:08 pm
by piert
Excellent!!!!

All is working beatifully now!!! Thank you Pako!!!!!!!
It is very convenient that you made the example XML configuration as this explains how the many options work. I don't have much time at the moment, but will investigate further in the weekend and will let you know if more questions pop up regarding usage.
One more question for now: what is the best way to make custom modifications to the Website? I would like to add text fields to bring in several other types of information and add buttons to create other Eventghost actions. Can you recommend software that allows easy editing of the web-page?
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 6:17 pm
by Pako
piert wrote:All is working beatifully now!!!
I'm glad we managed it together.
piert wrote:Can you recommend software that allows easy editing of the web-page?
I probably disappoint you, I use only a
plain text editor.
Pako
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 7:08 pm
by piert
Wow, respect!
The only disappointment is for myself; it means I will have to 'reverse-engineer' my way to modify the index page by means of trial and error
Ps: I now have two separate browsers connected to the same MusicBee control and in sync: one on the source laptop; the other a tablet on the same LAN. Indeed, instant sync without the frequent and annoying re-loading of the webpage. Thanks again, Pako, well done!!!
Re: Tornado (webserver with WebSocket)
Posted: Tue Jan 14, 2014 7:59 pm
by therealbiglou
Pako,
Would this be possible to use to create a web app similar to your MusicBee one for controlling Pandora in a browser?
Thanks!
Brian
Re: Tornado (webserver with WebSocket)
Posted: Wed Jan 15, 2014 4:30 am
by Pako
therealbiglou wrote:Would this be possible to use to create a web app similar to your MusicBee one for controlling Pandora in a browser?
I do not know.
I do not know what it is Pandora.
However, one thing is certain. If you can control Pandora via EventGhost,
then you can do it even through Tornado plugin.
Pako