]> git.basschouten.com Git - openhab-addons.git/blob
05b34aad96a5534ab64ad984ec0f43dfbf098c88
[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.ipcamera.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 import io.netty.channel.Channel;
18 import io.netty.channel.ChannelFuture;
19
20 /**
21  * The {@link ChannelTracking} Can be used to find the handle for a HTTP channel if you know the URL. The reply can
22  * optionally be stored for later use.
23  *
24  *
25  * @author Matthew Skinner - Initial contribution
26  */
27
28 @NonNullByDefault
29 public class ChannelTracking {
30     private String storedReply = "";
31     private String requestUrl = "";
32     private Channel channel;
33
34     public ChannelTracking(Channel channel, String requestUrl) {
35         this.channel = channel;
36         this.requestUrl = requestUrl;
37     }
38
39     public String getRequestUrl() {
40         return requestUrl;
41     }
42
43     public Channel getChannel() {
44         return channel;
45     }
46
47     /**
48      * Closes the channel, but keeps the HTTP reply stored in the tracker.
49      *
50      * @return ChannelFuture
51      */
52     public ChannelFuture closeChannel() {
53         return channel.close();
54     }
55
56     public String getReply() {
57         return storedReply;
58     }
59
60     public void setReply(String replyToStore) {
61         storedReply = replyToStore;
62     }
63
64     public void setChannel(Channel ch) {
65         channel = ch;
66     }
67 }