Ole8700 / openhab

Automatically exported from code.google.com/p/openhab
GNU General Public License v3.0
1 stars 0 forks source link

How to notify client, when an Item changes on the openHAB server #244

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Feature Description

By RSET API, client can get or post an item's state, but it is started by 
client.

When an item's state changes, hope openHAB server can notify client,just like 
observer pattern.

I know openHAB can implement this function. but REST API can do this?

2. Example Use Case

thanks!

Original issue reported on code.google.com by duanruiq...@gmail.com on 20 Apr 2013 at 2:10

GoogleCodeExporter commented 9 years ago
Hi, did you read the description of the REST API 
http://code.google.com/p/openhab/wiki/REST ? I think the chapter "Server push" 
describes what you was asking for, right?

Original comment by teichsta on 20 Apr 2013 at 9:24

GoogleCodeExporter commented 9 years ago
thanks teichsta
I did read the chapter "server push", the content of the chapter is introduced 
simply.

I implement it by adding http header like this:

        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet("http://localhost:8080/rest/items/Light_FF_Bath_Ceiling");

        httpGet.addHeader("X-Atmosphere-Transport", "websocket");
        httpGet.addHeader("X-Atmosphere-tracking-id", "5");

but i cannot gain the result i want
maybe i need more study.

Original comment by duanruiq...@gmail.com on 22 Apr 2013 at 4:14

GoogleCodeExporter commented 9 years ago
You need a WebSocket capable client. Or use long-polling and implement the 
receiving of the pushes yourself. Simply adding the header for websockets isn't 
enough, since WebSockets are different technology than HTTP. You should start 
by reading some documentation about WebSockets, long polling, streaming and 
normal polling. Then you can decide what technology suits best your scenario 
and what is the easiest to implement.

Original comment by till.klo...@gmail.com on 22 Apr 2013 at 8:57

GoogleCodeExporter commented 9 years ago
Thanks.
I understand your statement.

Original comment by duanruiq...@gmail.com on 22 Apr 2013 at 9:27

GoogleCodeExporter commented 9 years ago

Original comment by kai.openhab on 5 May 2013 at 6:45