]> git.basschouten.com Git - openhab-addons.git/blob
08ee0182d52fabb09eacc09d72cbb5804b60a24e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.orbitbhyve.internal.net;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.eclipse.jetty.websocket.api.WebSocketAdapter;
18 import org.openhab.binding.orbitbhyve.internal.handler.OrbitBhyveBridgeHandler;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 /**
23  * The {@link OrbitBhyveSocket} class defines websocket used for connection with
24  * the Orbit B-Hyve cloud.
25  *
26  * @author Ondrej Pecta - Initial contribution
27  */
28 @NonNullByDefault
29 public class OrbitBhyveSocket extends WebSocketAdapter {
30     private final Logger logger = LoggerFactory.getLogger(OrbitBhyveSocket.class);
31     private OrbitBhyveBridgeHandler handler;
32
33     public OrbitBhyveSocket(OrbitBhyveBridgeHandler handler) {
34         this.handler = handler;
35     }
36
37     @Override
38     public void onWebSocketText(@Nullable String message) {
39         super.onWebSocketText(message);
40         if (message != null) {
41             logger.trace("Got message: {}", message);
42             handler.processStatusResponse(message);
43         }
44     }
45 }