forked from eclipse-paho/paho.mqtt.golang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
options_reader.go
149 lines (122 loc) · 3.06 KB
/
options_reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* Copyright (c) 2013 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Seth Hoenig
* Allan Stockdill-Mander
* Mike Robertson
*/
package mqtt
import (
"crypto/tls"
"net/http"
"net/url"
"time"
)
// ClientOptionsReader provides an interface for reading ClientOptions after the client has been initialized.
type ClientOptionsReader struct {
options *ClientOptions
}
//Servers returns a slice of the servers defined in the clientoptions
func (r *ClientOptionsReader) Servers() []*url.URL {
s := make([]*url.URL, len(r.options.Servers))
for i, u := range r.options.Servers {
nu := *u
s[i] = &nu
}
return s
}
//ResumeSubs returns true if resuming stored (un)sub is enabled
func (r *ClientOptionsReader) ResumeSubs() bool {
s := r.options.ResumeSubs
return s
}
//ClientID returns the set client id
func (r *ClientOptionsReader) ClientID() string {
s := r.options.ClientID
return s
}
//Username returns the set username
func (r *ClientOptionsReader) Username() string {
s := r.options.Username
return s
}
//Password returns the set password
func (r *ClientOptionsReader) Password() string {
s := r.options.Password
return s
}
//CleanSession returns whether Cleansession is set
func (r *ClientOptionsReader) CleanSession() bool {
s := r.options.CleanSession
return s
}
func (r *ClientOptionsReader) Order() bool {
s := r.options.Order
return s
}
func (r *ClientOptionsReader) WillEnabled() bool {
s := r.options.WillEnabled
return s
}
func (r *ClientOptionsReader) WillTopic() string {
s := r.options.WillTopic
return s
}
func (r *ClientOptionsReader) WillPayload() []byte {
s := r.options.WillPayload
return s
}
func (r *ClientOptionsReader) WillQos() byte {
s := r.options.WillQos
return s
}
func (r *ClientOptionsReader) WillRetained() bool {
s := r.options.WillRetained
return s
}
func (r *ClientOptionsReader) ProtocolVersion() uint {
s := r.options.ProtocolVersion
return s
}
func (r *ClientOptionsReader) TLSConfig() *tls.Config {
s := r.options.TLSConfig
return s
}
func (r *ClientOptionsReader) KeepAlive() time.Duration {
s := time.Duration(r.options.KeepAlive * int64(time.Second))
return s
}
func (r *ClientOptionsReader) PingTimeout() time.Duration {
s := r.options.PingTimeout
return s
}
func (r *ClientOptionsReader) ConnectTimeout() time.Duration {
s := r.options.ConnectTimeout
return s
}
func (r *ClientOptionsReader) MaxReconnectInterval() time.Duration {
s := r.options.MaxReconnectInterval
return s
}
func (r *ClientOptionsReader) AutoReconnect() bool {
s := r.options.AutoReconnect
return s
}
func (r *ClientOptionsReader) WriteTimeout() time.Duration {
s := r.options.WriteTimeout
return s
}
func (r *ClientOptionsReader) MessageChannelDepth() uint {
s := r.options.MessageChannelDepth
return s
}
func (r *ClientOptionsReader) HTTPHeaders() http.Header {
h := r.options.HTTPHeaders
return h
}