2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.digitalstrom.internal.lib.listener;
16 * The {@link ConnectionListener} is notified if the connection state of digitalSTROM-Server has changed.
18 * @author Michael Ochel - Initial contribution
19 * @author Matthias Siegele - Initial contribution
22 public interface ConnectionListener {
24 /* Connection-States */
26 * State, if you're not authenticated on the digitalSTROM-Server.
28 final String NOT_AUTHENTICATED = "notAuth";
30 * State, if the connection to the digitalSTROM-Server is lost.
32 final String CONNECTION_LOST = "connLost";
34 * State, if a ssl handshake problem occured while communicating with the digitalSTROM-Server.
36 final String SSL_HANDSHAKE_ERROR = "sslHandshakeError";
38 * State, if the connection to the digitalSTROM-Server is resumed.
40 final String CONNECTION_RESUMED = "connResumed";
42 * State, if the Application-Token is generated.
44 final String APPLICATION_TOKEN_GENERATED = "appGen";
46 /* Not authentication reasons */
48 * State, if the given Application-Token cannot be used.
50 final String WRONG_APP_TOKEN = "wrongAppT";
52 * State, if the given username or password cannot be used.
54 final String WRONG_USER_OR_PASSWORD = "wrongUserOrPasswd";
56 * State, if no username or password is set and the given application-token cannot be used or is null.
58 final String NO_USER_PASSWORD = "noUserPasswd";
61 * State, if the connection timed out.
63 final String CONNECTON_TIMEOUT = "connTimeout";
66 * State, if the host address cannot be found.
68 final String HOST_NOT_FOUND = "hostNotFound";
71 * State, if the host address is unknown.
73 final String UNKNOWN_HOST = "unknownHost";
76 * State, if the the URL is invalid.
78 final String INVALID_URL = "invalideURL";
81 * This method is called whenever the connection state has changed from {@link #CONNECTION_LOST}
82 * to {@link #CONNECTION_RESUMED} and vice versa. It also will be called if the application-token is generated over
83 * {@link #APPLICATION_TOKEN_GENERATED}.
85 * @param newConnectionState of the connection
87 void onConnectionStateChange(String newConnectionState);
90 * This method is called whenever the connection state has changed to {@link #NOT_AUTHENTICATED} or
91 * {@link #CONNECTION_LOST}
92 * and also passes the reason why. Reason can be:
94 * <li>{@link #WRONG_APP_TOKEN} if the given application-token can't be used.</li>
95 * <li>{@link #WRONG_USER_OR_PASSWORD} if the given user name or password can't be used.</li>
96 * <li>{@link #NO_USER_PASSWORD} if no user name or password is set and the given application-token can't be
98 * <li>{@link #HOST_NOT_FOUND} if the host can't be found.</li>
99 * <li>{@link #INVALID_URL} if the the URL is invalid.</li>
102 * @param newConnectionState of the connection
103 * @param reason why the connection is failed
105 void onConnectionStateChange(String newConnectionState, String reason);