50 lines
977 B
Go
50 lines
977 B
Go
|
package arcast
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"forge.cadoles.com/arcad/arcast/pkg/client"
|
||
|
"forge.cadoles.com/arcad/edge/pkg/module/cast"
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
type Client struct {
|
||
|
client *client.Client
|
||
|
addr string
|
||
|
}
|
||
|
|
||
|
// Close implements cast.Client.
|
||
|
func (c *Client) Close() error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Load implements cast.Client.
|
||
|
func (c *Client) Load(ctx context.Context, url string) error {
|
||
|
if _, err := c.client.Cast(ctx, c.addr, url); err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Status implements cast.Client.
|
||
|
func (c *Client) Status(ctx context.Context) (cast.DeviceStatus, error) {
|
||
|
status, err := c.client.Status(ctx, c.addr)
|
||
|
if err != nil {
|
||
|
return nil, errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
return &DeviceStatus{status}, nil
|
||
|
}
|
||
|
|
||
|
// Unload implements cast.Client.
|
||
|
func (c *Client) Unload(ctx context.Context) error {
|
||
|
if _, err := c.client.Reset(ctx, c.addr); err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
var _ cast.Client = &Client{}
|