]> git.basschouten.com Git - openhab-addons.git/blob
d5a94b25003f3b45a31f979288ed29f22cbb4702
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.webthing.internal.client;
14
15 import java.util.function.BiConsumer;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The WebsocketConnection represents an open WebSocket connection on the Web Thing. It provides a realtime mechanism
21  * to be notified of events as soon as they happen. Refer https://iot.mozilla.org/wot/#web-thing-websocket-api
22  *
23  * @author Gregor Roth - Initial contribution
24  */
25 @NonNullByDefault
26 interface WebSocketConnection {
27
28     /**
29      * Makes a request for Property value change notifications
30      *
31      * @param propertyName the property to be observed
32      * @param listener the listener to call on changes
33      */
34     void observeProperty(String propertyName, BiConsumer<String, Object> listener);
35
36     /**
37      * closes the WebSocket connection
38      */
39     void close();
40
41     /**
42      * @return true, if connection is alive
43      */
44     boolean isAlive();
45 }