Pako,
my mistake. I tried to simplify things last minute with
socket.gethostbyname(socket.gethostname()). I uploaded a new version allowing you to give the host ip address. As long as this address and the address listed in the html client are the same it should connect. I use chrome, and safari on my iphone.
If you are still having problems try loading the html file through that ip address and not
"localhost" or
"file:///". As part as the websocket security it has to make sure its all the same.
It should be noted currently websockets are not supported in internet explorer. I'm not sure about firefox. Chrome and Safari work fine though.
krambriw and Mannyman,
Download the new version (0.9.3). As I told Pako you should specify the ip address of your computer eventghost is running on.
If your using the tester configuration, I would change the host address, then disable it.
The html file's location is where ever your webserver is configured. I use eventghost's webserver plugin.
The websocket connection function can just be added to your existing setup.
Code: Select all
var ws = '';
function WebSocket() {
ws = new WebSocket("ws://192.168.0.101:1235");
ws.onopen = function() {
alert("Connected");
};
ws.onmessage = function (event) {
alert(event.data);
};
ws.onclose = function() {
ws = ''
alert('Connection Closed');
};
}
You need to change
ws = new WebSocket("ws://
192.168.0.101:1235");
to the same ip address listed in eventghost.
The ws variable listed before the function allows you to access the websocket outside of the function. Such as,
I don't really see the use for this though, since html clients can already send data to eventghost whenever.
Like I said before the main advantage of using websockets is the ability for eventghost to send data to the html client immediately without polling or separate text files.
You can put whatever you want in onopen/onmessage/onclose.
onopen is called when the client connects to the server
onclose is called when the client disconnects from the server
onmessage is called when the send message action in eventghost is triggered
The poke button triggers an event in eventghost.
You could setup a macro in eventghost to send an event when poke is received.
Code: Select all
if (eg.event.payload == "POKE"):
eg.plugins.WebSocketPlugin.SendMessageAll("Quit Poking Me!")
Right now, when you send a message to eventghost (with ws.send) it triggers the action WebSocket.Message is the payload as the message.
Is this a good way to do it? Or should I just have the message as the eventname?