@@ -32,6 +32,7 @@ type Client struct {
32
32
Categories
33
33
34
34
conn * websocket.Conn
35
+ scheme string
35
36
host string
36
37
password string
37
38
dialer * websocket.Dialer
@@ -85,6 +86,17 @@ func WithResponseTimeout(x time.Duration) Option {
85
86
return func (o * Client ) { o .client .ResponseTimeout = time .Duration (x ) }
86
87
}
87
88
89
+ // WithScheme sets the protocol scheme to use when connecting to the server,
90
+ // e.g. "ws" or "wss". The default is "ws". Please note however that the
91
+ // obs-websocket server does not currently support connecting over wss (ref:
92
+ // https://github.com/obsproject/obs-websocket/issues/26). To be able to
93
+ // connect over wss, you'll need to firest set up a reverse proxy in front of
94
+ // the server. The obs-websocket folks have a guide here:
95
+ // https://github.com/obsproject/obs-websocket/wiki/SSL-Tunneling.
96
+ func WithScheme (x string ) Option {
97
+ return func (o * Client ) { o .scheme = x }
98
+ }
99
+
88
100
/*
89
101
Disconnect sends a message to the OBS websocket server to close the client's
90
102
open connection. You should defer a disconnection after creating your client to
@@ -140,6 +152,7 @@ It also opens up a connection, so be sure to check the error.
140
152
*/
141
153
func New (host string , opts ... Option ) (* Client , error ) {
142
154
c := & Client {
155
+ scheme : "ws" ,
143
156
host : host ,
144
157
dialer : websocket .DefaultDialer ,
145
158
requestHeader : http.Header {"User-Agent" : []string {"goobs/" + LibraryVersion }},
@@ -186,7 +199,7 @@ func New(host string, opts ...Option) (*Client, error) {
186
199
}
187
200
188
201
func (c * Client ) connect () (err error ) {
189
- u := url.URL {Scheme : "ws" , Host : c .host }
202
+ u := url.URL {Scheme : c . scheme , Host : c .host }
190
203
191
204
c .client .Log .Printf ("[INFO] Connecting to %s" , u .String ())
192
205
0 commit comments