websocket client

Discussions about Z-Way software and Z-Wave technology in general
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: websocket client

Post by pofs »

There's already some updates' pushes performed in AutomationController.js, but they're implemented wrong (push requires two arguments, not one).
Generally yes, you need some kind of module which will push updates for you.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: websocket client

Post by pz1 »

pofs wrote:There's already some updates' pushes performed in AutomationController.js, but they're implemented wrong (push requires two arguments, not one).
Generally yes, you need some kind of module which will push updates for you.
Has it been fixed in AutomationController.js, or is the task left for community Module developers?
kenavn
Posts: 1
Joined: 05 Jul 2016 23:25

Re: websocket client

Post by kenavn »

Well, can anyone answer the last question although it's been a while? :D

I still see the push in AutomationController.js source code with 1 parameter. And when connecting to the websocket nothing comes out. Ever.

It would be very beneficial to know;
- Is the websocket implementation ment to be working as it is pr. the latest version?
- Is the websocket in any way restricted by authentication, and if so, what user type needs to connect. Admin?
- Is the websocket implementation limited to local clients only?
pah111kg
Posts: 25
Joined: 02 Sep 2016 18:49

Re: websocket client

Post by pah111kg »

Hi,

@kenavn: source code in AutomationController.js has two parameters now but still does not seem to work.

I'm currently working on a WebSocket client for Java. The connection to the server works and I can send custom message from my Z-Way module to the Java client.

Code: Select all

var message = { msg: 'Hello, World!' };
ws.push("my.custom.event", message);
But I don't get the default messages from AutomationController.js (Ln 84-136), for example:

Code: Select all

ws.push({
    type: "me.z-wave.devices.title_update",
    data: JSON.stringify(device.toJSON())
});
If I change the code as follows, I get the messages:

Code: Select all

ws.push("me.z-wave.devices.title_update", JSON.stringify(device.toJSON()));
Any idea? Is this a Z-Way bug or a client problem? Could anyone ever receive the default messages?

Many thanks for all your help.

Regards,
Patrick
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: websocket client

Post by PoltoS »

We do in push a JSON_stringify, so in your case it is done twice and a string comes to your client. May be client do not accept objects?
pah111kg
Posts: 25
Joined: 02 Sep 2016 18:49

Re: websocket client

Post by pah111kg »

Thanks for your answer!

I have just tried again with the following code in Z-Way:

1.)

Code: Select all

var message = { msg: 'Hello, World!' };
ws.push("my.custom.event", message);
2.)

Code: Select all

ws.push("plain text");
3.)

Code: Select all

ws.push({
		type: "my.custom.event.default",
		data: JSON.stringify(message)
	});
Only 1.) reaches the Java client as JSON string: {"type":"my.custom.event","data":{"msg":"Hello, World!"}}

I have also tested a JavaScript client with the same result. Only the first variant reaches the client.

If you can confirm this, please check my pull request.

Regards,
Patrick
Attachments
Z-Way app.zip
Z-Way app (index.js)
(867 Bytes) Downloaded 301 times
JavaScript code.zip
JavaScript client
(383 Bytes) Downloaded 283 times
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: websocket client

Post by PoltoS »

Correct! You are right. I missed the API change.
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: websocket client

Post by PoltoS »

Unfortunatelly not part of v.2.2.4 release ;(
injecteer
Posts: 13
Joined: 29 Sep 2016 16:28

Re: websocket client

Post by injecteer »

What's the difference between `ws.push()` and `ws.send()`?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: websocket client

Post by PoltoS »

There is no ws.send() ;)
Post Reply