Websocket suite

Questions and comments specific to a particular plugin should go here.

Websocket suite

Postby Pako » Mon Sep 26, 2011 1:46 pm

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
WS_Package.zip
(87.38 KiB) Downloaded 216 times


EDIT 2012-01-16: Added version 0.0.5
Attachments
__init__.py
Plugin Websocket suite - version 0.0.5
(187.37 KiB) Downloaded 128 times
__init__.py
Plugin Websocket suite - version 0.0.4
(186.98 KiB) Downloaded 89 times
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Websocket suite

Postby piert » Tue Sep 27, 2011 7:22 am

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.


This is really confusing, Pako. You created a plugin that you can not use or test yourself?

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
piert
Experienced User
 
Posts: 116
Joined: Tue Jun 14, 2011 2:53 pm

Re: Websocket suite

Postby Pako » Tue Sep 27, 2011 7:38 am

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
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Websocket suite

Postby Pako » Tue Sep 27, 2011 10:52 am

piert wrote:This is really confusing, Pako. You created a plugin that you can not use or test yourself?
Now I realized that I misunderstood your question.
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
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Websocket suite

Postby jinxdone » Tue Sep 27, 2011 12:17 pm

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..
User avatar
jinxdone
Plugin Developer
 
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Websocket suite

Postby Pako » Tue Sep 27, 2011 3:20 pm

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.
It is quite possible.
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
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Websocket suite

Postby cfull1 » Tue Oct 04, 2011 12:14 am

I'll check it out Pako!
cfull1
Experienced User
 
Posts: 99
Joined: Thu Aug 19, 2010 4:52 am

Re: Websocket suite

Postby Livin » Tue Oct 04, 2011 6:16 am

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... :)
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
User avatar
Livin
Experienced User
 
Posts: 749
Joined: Wed Oct 08, 2008 4:56 am

Re: Websocket suite

Postby cfull1 » Thu Oct 06, 2011 10:31 pm

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:
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


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!
cfull1
Experienced User
 
Posts: 99
Joined: Thu Aug 19, 2010 4:52 am

Re: Websocket suite

Postby Pako » Fri Oct 07, 2011 9:19 am

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
Thank you for the warning. I guess I had to change something because it worked before. I look at it.

cfull1 wrote:What are the advantages of using server/client classes and persistent variables and actions?
Client classes are not yet done :D . When I created the Server classes, I thought this (simplified):
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:
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
That is why I have to incorporate PV into this plugin.
It extends the possibilities of using this plugin. You can even use this plugin without WebSocket protocol used. See topic Persistent variables ?

cfull1 wrote:Have you thought about adding a flash policy so android and other devices can use the connection?
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.

Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Websocket suite

Postby cfull1 » Fri Oct 07, 2011 8:15 pm

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? :D
If you indeed to buy that tablet you'll need this though.
cfull1
Experienced User
 
Posts: 99
Joined: Thu Aug 19, 2010 4:52 am

Re: Websocket suite

Postby krambriw » Sat Oct 08, 2011 6:17 am

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
krambriw
Plugin Developer
 
Posts: 1144
Joined: Sat Jun 30, 2007 2:51 pm

Re: Websocket suite

Postby Pako » Sat Oct 08, 2011 7:38 am

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.
Yes, so it of course works.


cfull1 wrote:Are the actions for the server classes supposed to replace the common macros? I'm not sure I follow those either...
This question, unfortunately I do not understand. Can you please write in other words?


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? :D
If you indeed to buy that tablet you'll need this though.
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: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
In the initial contribution is a fixed version (0.0.4).

Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Websocket suite

Postby cfull1 » Mon Oct 10, 2011 12:57 pm

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?


Pako wrote:Yes, so it of course works.

So your saying when you set the new variable it automatically broadcasts to connected clients or I need to do this myself?

Pako wrote:This question, unfortunately I do not understand. Can you please write in other words?

The Action tab in server classes next to persistent variables. What is the purpose?


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.
cfull1
Experienced User
 
Posts: 99
Joined: Thu Aug 19, 2010 4:52 am

Re: Websocket suite

Postby Pako » Mon Oct 10, 2011 3:24 pm

cfull1 wrote:So your saying when you set the new variable it automatically broadcasts to connected clients or I need to do this myself?
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:The Action tab in server classes next to persistent variables. What is the purpose?
This sentence is completely incomprehensible to me.


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
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Next

Return to Plugin Support

Who is online

Users browsing this forum: No registered users and 1 guest