]> git.basschouten.com Git - openhab-addons.git/blob
e09bff058ac5905ac6acdf2e707f0fad0544f815
[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.samsungtv.internal.protocol;
14
15 import java.util.List;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * The {@link RemoteController} is the base class for handling remote control keys for the Samsung TV.
22  *
23  * @author Arjan Mels - Initial contribution
24  */
25 @NonNullByDefault
26 public abstract class RemoteController implements AutoCloseable {
27     protected String host;
28     protected int port;
29     protected String appName;
30     protected String uniqueId;
31
32     public RemoteController(String host, int port, @Nullable String appName, @Nullable String uniqueId) {
33         this.host = host;
34         this.port = port;
35         this.appName = appName != null ? appName : "";
36         this.uniqueId = uniqueId != null ? uniqueId : "";
37     }
38
39     public abstract void openConnection() throws RemoteControllerException;
40
41     public abstract boolean isConnected();
42
43     public abstract void sendKey(KeyCode key) throws RemoteControllerException;
44
45     public abstract void sendKeys(List<KeyCode> keys) throws RemoteControllerException;
46
47     @Override
48     public abstract void close() throws RemoteControllerException;
49 }