Documentation ¶
Overview ¶
Package api is the intermediary API between the top-level goobs client and the category-level subclients.
Nothing in this package should be of interest to a user.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // The time we're willing to wait to receive a response from the server. ResponseTimeout time.Duration // This client sends raw opcodes it got from the server to this channel. Opcodes chan opcodes.Opcode // Once the top-level has parsed the raw opcode, it sends the response // to this channel. IncomingResponses chan *opcodes.RequestResponse // Ya like logs? Log Logger Disconnected chan struct{} // contains filtered or unexported fields }
Client represents a minimal client to the OBS websocket server.
func (*Client) SendRequest ¶
SendRequest abstracts the logic every subclient uses to send a request and receive the corresponding response.
To get the response for a sent request, we simply read the next response off our incoming responses channel. This works fine in a single-threaded context, and the message IDs of both the sent request and response should match.
A request ID and response ID mismatch could happen if the server processes requests in a different order it received them (e.g. we should 1, then 2; but it processes 2, and then 1). In this case there'll be an error, so note the mutex lock and deferred unlock to prevent this from happening.
It should be noted multiple connections to the server are totally fine. Phrased differently, mesasge IDs are unique per client. Moreover, events will be broadcast to every client.
type Logger ¶
Logger is a interface compatible with both the stdlib's logger and some third-party loggers.
type LoggerWithWrite ¶
LoggerWithWrite helps us anonymously satisfy a Writer interface
type Response ¶ added in v1.0.0
type Response interface { GetRaw() json.RawMessage // contains filtered or unexported methods }
type ResponseCommon ¶ added in v1.0.0
type ResponseCommon struct {
// contains filtered or unexported fields
}
func (*ResponseCommon) GetRaw ¶ added in v1.0.0
func (o *ResponseCommon) GetRaw() json.RawMessage