This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
requests.go
65 lines (52 loc) · 1.78 KB
/
requests.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
package obsws
import "errors"
const (
// StatusOK indicates that the request was successful.
StatusOK = "ok"
// StatusError indicates that the request was unsuccessful.
StatusError = "error"
)
var (
// ErrNotSent is returned when you call Receive on a request that has not been sent.
ErrNotSent = errors.New("request not yet sent")
// ErrAlreadySent is returned when a request has already been sent.
ErrAlreadySent = errors.New("request already sent")
)
// Request is a request to obs-websocket.
type Request interface {
ID() string
Type() string
Send(Client) error
}
// Response is a response from obs-websocket.
type Response interface {
ID() string
Status() string
Error() string
}
// https://github.com/Palakis/obs-websocket/blob/master/docs/generated/protocol.md#requests
type _request struct {
ID_ string `json:"message-id"`
Type_ string `json:"request-type"`
sent bool
err chan error
}
func (r _request) Send(c Client) error { return nil }
// ID returns the request's message ID.
func (r _request) ID() string { return r.ID_ }
// Type returns the request's message type.
func (r _request) Type() string { return r.Type_ }
// https://github.com/Palakis/obs-websocket/blob/master/docs/generated/protocol.md#requests
type _response struct {
ID_ string `json:"message-id"`
Status_ string `json:"status"`
Error_ string `json:"error"`
}
// ID returns the response's message ID.
func (r _response) ID() string { return r.ID_ }
// Status returns the response's status.
func (r _response) Status() string { return r.Status_ }
// Error returns the response's error.
// When using Receive or SendReceive, this should always return an empty string,
// because the error will have been returned explictly instead of stored here.
func (r _response) Error() string { return r.Error_ }