primitives

package
v0.0.0-...-700dddc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	DestinationID string
	// contains filtered or unexported fields
}

Channel is an abstraction over a chromecast channel.

func (*Channel) OnMessage

func (c *Channel) OnMessage(responseType string, cb func(*api.CastMessage))

OnMessage adds a callback listener for a certain type of message with specified responseType

func (*Channel) Request

func (c *Channel) Request(payload HasRequestID, timeout time.Duration) (*api.CastMessage, error)

Request sends a payload and returns the message the chromecast gives back. Throws an error if timeout has passed waiting for the message to be returned.

func (*Channel) Send

func (c *Channel) Send(payload interface{}) error

Send creates a simple message to be sent by the client.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a basic connector to the chromecast event stream.

func NewClient

func NewClient(host net.IP, port int) (*Client, error)

NewClient is a constructor for a Client object. Host and Port are for the chromecast's network info.

func (*Client) Close

func (c *Client) Close()

Close closes the real socket connection that the client has to the chromecast.

func (*Client) NewChannel

func (c *Client) NewChannel(sourceID, destinationID, namespace string) *Channel

NewChannel constructs a communication channel towards a chromecast device with a specified namespace. namespace are those namespaces that are specified by the chromecast API.

func (*Client) Send

func (c *Client) Send(message *api.CastMessage) error

Send sends a message to the chromecast using the actual socket connection.

type HasRequestID

type HasRequestID interface {
	// contains filtered or unexported methods
}

HasRequestID is a generic type describing any form of request to a channel. All requests need to have a request id.

type PayloadHeaders

type PayloadHeaders struct {
	Type      string `json:"type"`
	RequestID *int   `json:"requestId,omitempty"`
}

PayloadHeaders are general request components for any message to be passed to a chromecast.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL