Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Websocket suite
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Websocket suite
I think it's time to acquaint you with what I created on theme Websocket.
I named my new plugin Websocket suite.
I knew that in order to demonstrate the possibilities of this plugin I need an external device.
But there is a problem. I do not own any suitable equipment.
But even if I owned any device, even so it was a problem.
Anyone interested should try the Websocket suite he would also have the same equipment.
So I first created a program that is called Virtual house.
It can "live" their own lives. You can try it. You will see that the program does nothing useful.
As a next step I had to do a plugin through which you may control the Virtual house.
Note that this plugin is included in the category External Equipment.
The last step then was to create html websocket client, through which can also control the Virtual house.
Only in this moment, everyone can easily try out what you can do with Websocket suite plugin.
I recommend the following:
1. Download VirtualHouse.exe and attached zip file. Extract the zip file.
2. The two folders VirtualHouse and WebsocketSuite move into the folder EventGhost\plugins\
3. The two files VirtualHouse.exe and Websocket_Client.html you can place anywhere
4. You can run VirtualHouse.exe and play with it. It remembers the last state, even when you close it and restart.
5. In the program EventGhost, you open the file WebsocketSuiteDemo.xml
6. In a web browser, open the file Websocket_Client.html. I recommend use BlackHawk browser, but you can also use Chrome.
7. Websocket_Client.html file you can open multiple times (in multiple windows or tabs) and also in more computers.
If you use a different computer than where the server is running, you must to replace the word localhost in the source text either by IP address or name of the computer on that is running the server.
8. Now you can already play with it. You can try to change various parameters and see what happens. Parameters can be changed
either by the html client or using the Virtual house plugin or directly in Virtual house.
9. To understand how it works, you have to study file Websocket_Client.html and mainly setting Server classes .... To get to this setting, you must press the button, which can be found in the main configuration dialogue of Websocket suite plugin. Do not forget to try the context menu that can be invoked by right mouse button on most tables.
10. Furthermore, I suggest you turn on the option Log commands to following logfile:, which you will find on page Options. Then occasionally check the contents of the logfile.
Pako
VirtualHouse.exe Size: 18 MiB EDIT 2012-01-16: Added version 0.0.5
I named my new plugin Websocket suite.
I knew that in order to demonstrate the possibilities of this plugin I need an external device.
But there is a problem. I do not own any suitable equipment.
But even if I owned any device, even so it was a problem.
Anyone interested should try the Websocket suite he would also have the same equipment.
So I first created a program that is called Virtual house.
It can "live" their own lives. You can try it. You will see that the program does nothing useful.
As a next step I had to do a plugin through which you may control the Virtual house.
Note that this plugin is included in the category External Equipment.
The last step then was to create html websocket client, through which can also control the Virtual house.
Only in this moment, everyone can easily try out what you can do with Websocket suite plugin.
I recommend the following:
1. Download VirtualHouse.exe and attached zip file. Extract the zip file.
2. The two folders VirtualHouse and WebsocketSuite move into the folder EventGhost\plugins\
3. The two files VirtualHouse.exe and Websocket_Client.html you can place anywhere
4. You can run VirtualHouse.exe and play with it. It remembers the last state, even when you close it and restart.
5. In the program EventGhost, you open the file WebsocketSuiteDemo.xml
6. In a web browser, open the file Websocket_Client.html. I recommend use BlackHawk browser, but you can also use Chrome.
7. Websocket_Client.html file you can open multiple times (in multiple windows or tabs) and also in more computers.
If you use a different computer than where the server is running, you must to replace the word localhost in the source text either by IP address or name of the computer on that is running the server.
8. Now you can already play with it. You can try to change various parameters and see what happens. Parameters can be changed
either by the html client or using the Virtual house plugin or directly in Virtual house.
9. To understand how it works, you have to study file Websocket_Client.html and mainly setting Server classes .... To get to this setting, you must press the button, which can be found in the main configuration dialogue of Websocket suite plugin. Do not forget to try the context menu that can be invoked by right mouse button on most tables.
10. Furthermore, I suggest you turn on the option Log commands to following logfile:, which you will find on page Options. Then occasionally check the contents of the logfile.
Pako
VirtualHouse.exe Size: 18 MiB EDIT 2012-01-16: Added version 0.0.5
- Attachments
-
- __init__.py
- Plugin Websocket suite - version 0.0.5
- (187.37 KiB) Downloaded 416 times
-
- __init__.py
- Plugin Websocket suite - version 0.0.4
- (186.98 KiB) Downloaded 327 times
Re: Websocket suite
This is really confusing, Pako. You created a plugin that you can not use or test yourself?Pako wrote: I knew that in order to demonstrate the possibilities of this plugin I need an external device.
But there is a problem. I do not own any suitable equipment.
I have found out that your plugins generally turn out to be very useful, so I plan to try this out when I have time this weekend.
However, it would be nice if you could describe in a few short words what this plugin actually does.
Thanks and regards,
Perry
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Websocket suite
I also previously did not understand what is good WebSocket.
You can see it in the topic Websocket plugin.
I think there will also find an answer to your question.
Pako
You can see it in the topic Websocket plugin.
I think there will also find an answer to your question.
Pako
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Websocket suite
Now I realized that I misunderstood your question.piert wrote:This is really confusing, Pako. You created a plugin that you can not use or test yourself?
Yes, I created a plugin, which (for this moment) I do not need.
I can explain it.
I think websocket has great potential for its application and it is still multiplied by its combination with the program EventGhost.
In addition, it is also an interesting toy. Try to play with it!
I think that soon I can find some use for it.
There is no need for any hardware. For example, I can transfer to any PC in the network information about which song is being played.
Pako
Re: Websocket suite
I assume this is basically a websocket enabled http server plugin for eventghost ?
The general idea with websockets is that you can build more efficient javascript/html apps that either need realtime data or a constant stream. For example back when I was testing websockets (with apache) I made a telnet client javascript app that connected to a telnet service on the server using a websocket connection..
I'm not quite sure if this will be so useful with EG though, since you can just use ajax with the regular webserver plugin -- which is the standard way to do these things at the moment. Not that I'm opposed to having websocket support, I have to check it out..
The general idea with websockets is that you can build more efficient javascript/html apps that either need realtime data or a constant stream. For example back when I was testing websockets (with apache) I made a telnet client javascript app that connected to a telnet service on the server using a websocket connection..
I'm not quite sure if this will be so useful with EG though, since you can just use ajax with the regular webserver plugin -- which is the standard way to do these things at the moment. Not that I'm opposed to having websocket support, I have to check it out..
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Websocket suite
It is quite possible.jinxdone wrote:I'm not quite sure if this will be so useful with EG though, since you can just use ajax with the regular webserver plugin -- which is the standard way to do these things at the moment.
I really am not a programmer, I miss a lot of basic knowledge.
For instance, I know absolutely nothing about AJAX. I just know that it exists.
Pako
Re: Websocket suite
I'll check it out Pako!
Re: Websocket suite
this should be very useful for app integrations... for media center apps like WMC, XBMC, etc and Home Automation apps.
Now to find an XBMC dev to build out the XBMC side...
Now to find an XBMC dev to build out the XBMC side...
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Websocket suite
It's looking really good!
What are the advantages of using server/client classes and persistent variables and actions?
When I try to stop all servers, the server that has a class assigned to it produces this error:
Have you thought about adding a flash policy so android and other devices can use the connection?
Again looking really nice. I'm glad someone more experienced was able make this happen!
What are the advantages of using server/client classes and persistent variables and actions?
When I try to stop all servers, the server that has a class assigned to it produces this error:
Code: Select all
Exception in thread WebsocketServerHandler:
Traceback (most recent call last):
File "threading.pyc", line 532, in __bootstrap_inner
File "threading.pyc", line 484, in run
File "C:\Program Files\EventGhost\plugins\WebsocketSuite\__init__.py", line 3261, in ServerHandler
client[0].shutdown(socket.SHUT_RDWR)
TypeError: '_socketobject' object does not support indexingAgain looking really nice. I'm glad someone more experienced was able make this happen!
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Websocket suite
Thank you for the warning. I guess I had to change something because it worked before. I look at it.cfull1 wrote:When I try to stop all servers, the server that has a class assigned to it produces this error:Code: Select all
Exception in thread WebsocketServerHandler: Traceback (most recent call last): File "threading.pyc", line 532, in __bootstrap_inner File "threading.pyc", line 484, in run File "C:\Program Files\EventGhost\plugins\WebsocketSuite\__init__.py", line 3261, in ServerHandler client[0].shutdown(socket.SHUT_RDWR) TypeError: '_socketobject' object does not support indexing
Client classes are not yet donecfull1 wrote:What are the advantages of using server/client classes and persistent variables and actions?
The setting is quite complex. If this setting would be part of the action Start server, it could easily be lost after the deletion action.
Thus, when this setting is included in the plugin settings, it is not so easy to lose/delete. In addition, multiple servers can share the same class.
Persistent variables (PV):
I personally have for it (yet) no use. But I agree with this contribution:
That is why I have to incorporate PV into this plugin.krambriw wrote:Now I plan to put a number of flat touch panels around in the house to enable a visual view and control functions using buttons & status indicators on an html page.
The devices can, besides using EG, also be controlled by various remotes. Those signals (coming from remotes and others) are captured by EG too, just to have the actual status correctly represented
The websocket server works fine to control the status indicators, they are changing accordingly to show the actual status. So far so good!
The remaing parts I have to think about is
- I need to make the current statuses persistent to make it possible to restart EG and to recover the correct display on all connected web clients
- I need to make it possible so that when a new web client connects, it shall be synchronized with the current statuses
- When I touch a button on the touch screen to control a device, I need to make sure that the page is not fully refreshed to its default state, it should only update the changed status of the specific device
To save the current statuses I think I have to solve this by creating (a script or a plugin)
- that saves the status for each device when it changes using eg.PersistentData
- that sends out the current statuses to a web client when it detects that it is newly connected
It extends the possibilities of using this plugin. You can even use this plugin without WebSocket protocol used. See topic Persistent variables ?
Can you please explain what a flash policy? I've never heard of it. It will probably be that I have no device that contains Android. However, I found Gemei HD8900 Pro 5". I intend to buy it. Then I'll be able to work on further improvements of the new plugin.cfull1 wrote:Have you thought about adding a flash policy so android and other devices can use the connection?
Pako
Re: Websocket suite
I'm not sure if I understand the classes fully but I'll keep messing around with them.
I do understand the persistent variables better. It's a good idea too.
It seems like it would be logical to automatically broadcast the variables when they get updated to the clients not just when the first connect.
Are the actions for the server classes supposed to replace the common macros? I'm not sure I follow those either...
The Android OS doesn't support native websockets unfortunately. I'm not sure how it works fully, but you can use flash to act like a websocket connection.
socket.io is a good example of this, and tornadio is a good python implementation of socket.io. It's supposed to pick the best method for transport, websocket being the best, flash socket being next, down to ajax long polling. I managed to scrap it together into a buggy plugin and it works pretty good for android.
This is probably a big undertaking, but maybe a good direction for this plugin. maybe websocket suite 2.0?
If you indeed to buy that tablet you'll need this though.
I do understand the persistent variables better. It's a good idea too.
It seems like it would be logical to automatically broadcast the variables when they get updated to the clients not just when the first connect.
Are the actions for the server classes supposed to replace the common macros? I'm not sure I follow those either...
The Android OS doesn't support native websockets unfortunately. I'm not sure how it works fully, but you can use flash to act like a websocket connection.
socket.io is a good example of this, and tornadio is a good python implementation of socket.io. It's supposed to pick the best method for transport, websocket being the best, flash socket being next, down to ajax long polling. I managed to scrap it together into a buggy plugin and it works pretty good for android.
This is probably a big undertaking, but maybe a good direction for this plugin. maybe websocket suite 2.0?
If you indeed to buy that tablet you'll need this though.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: Websocket suite
Hi,
I am successfully using Opera as browser and so far it seem to support websockets fine. Also on my old symbian Nokia phone.
Are you saying that Opera wont support websockets on Android? According to the Opera spec it should.
Do you have an Android phone/pad and can test it?
Best regards, Walter
I am successfully using Opera as browser and so far it seem to support websockets fine. Also on my old symbian Nokia phone.
Are you saying that Opera wont support websockets on Android? According to the Opera spec it should.
Do you have an Android phone/pad and can test it?
Best regards, Walter
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Websocket suite
Yes, so it of course works.cfull1 wrote:It seems like it would be logical to automatically broadcast the variables when they get updated to the clients not just when the first connect.
This question, unfortunately I do not understand. Can you please write in other words?cfull1 wrote:Are the actions for the server classes supposed to replace the common macros? I'm not sure I follow those either...
I read somewhere that it is preparing Chrome for Android. And so it is possible that before I become familiar with Android, the problem will resolved.cfull1 wrote:The Android OS doesn't support native websockets unfortunately. I'm not sure how it works fully, but you can use flash to act like a websocket connection.
socket.io is a good example of this, and tornadio is a good python implementation of socket.io. It's supposed to pick the best method for transport, websocket being the best, flash socket being next, down to ajax long polling. I managed to scrap it together into a buggy plugin and it works pretty good for android.
This is probably a big undertaking, but maybe a good direction for this plugin. maybe websocket suite 2.0?![]()
If you indeed to buy that tablet you'll need this though.
In the initial contribution is a fixed version (0.0.4).cfull1 wrote:When I try to stop all servers, the server that has a class assigned to it produces this error:Code: Select all
Exception in thread WebsocketServerHandler: Traceback (most recent call last): File "threading.pyc", line 532, in __bootstrap_inner File "threading.pyc", line 484, in run File "C:\Program Files\EventGhost\plugins\WebsocketSuite\__init__.py", line 3261, in ServerHandler client[0].shutdown(socket.SHUT_RDWR) TypeError: '_socketobject' object does not support indexing
Pako
Re: Websocket suite
I've been unable to get the latest version of Opera to make a connection with the plugin.
I also tried opera mobile on my roommates droid x and it crashed trying to load my webpage.
Chrome works fine though...There shouldn't be a difference in how the connection is made based on the browser should it?
I'm surprised android hasn't added support for native websockets already, maybe because of its lack of security.
Releasing a browser for it would be the easiest fix though.
I also tried opera mobile on my roommates droid x and it crashed trying to load my webpage.
Chrome works fine though...There shouldn't be a difference in how the connection is made based on the browser should it?
So your saying when you set the new variable it automatically broadcasts to connected clients or I need to do this myself?Pako wrote:Yes, so it of course works.
The Action tab in server classes next to persistent variables. What is the purpose?Pako wrote:This question, unfortunately I do not understand. Can you please write in other words?
I'm surprised android hasn't added support for native websockets already, maybe because of its lack of security.
Releasing a browser for it would be the easiest fix though.
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Websocket suite
Of course it is automatic. You only have to assign the required variables to the Server class. This is just one reason why there is a Server class.cfull1 wrote:So your saying when you set the new variable it automatically broadcasts to connected clients or I need to do this myself?
This sentence is completely incomprehensible to me.cfull1 wrote:The Action tab in server classes next to persistent variables. What is the purpose?
I will try to clarify the meaning of the Server classes:
1. Tab Options - I think that the meaning of this tab is quite obvious.
2. Table Persistent variables - I hope that the meaning of this tab is now also obvious.
3. Tab Actions - Here you can define templates for some action. The client can execute the defined action as it is
(client starts the action with no arguments) or can be put (for example) only one argument.
Other arguments are used from the definition template.
Another advantage is that the result of the action is automatically sent to all clients.
You can also define actions that should be automatically perform after the client connection.
Another advantage is that you do not need to create macros and assign events to them.
Pako