Skip to content

Commit

Permalink
Add Device() to client.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnybug committed Apr 2, 2016
1 parent ad7327c commit fce0e9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

type Client struct {
name string
uuid string
info map[string]string
host net.IP
port int
conn *castnet.Connection
Expand Down Expand Up @@ -59,12 +59,16 @@ func (c *Client) Name() string {
return c.name
}

func (c *Client) SetUuid(uuid string) {
c.uuid = uuid
func (c *Client) SetInfo(info map[string]string) {
c.info = info
}

func (c *Client) Uuid() string {
return c.uuid
return c.info["id"]
}

func (c *Client) Device() string {
return c.info["md"]
}

func (c *Client) String() string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func discoverCommand(c *cli.Context) {
discover := discovery.NewService(ctx)
go func() {
for client := range discover.Found() {
fmt.Printf("Found: %s:%d '%s'\n", client.IP(), client.Port(), client.Name())
fmt.Printf("Found: %s:%d '%s' (%s)\n", client.IP(), client.Port(), client.Name(), client.Device())
}
}()
fmt.Printf("Running discovery for %s...\n", timeout)
Expand Down
2 changes: 1 addition & 1 deletion discovery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (d *Service) listener(ctx context.Context) {
client.SetName(decodeDnsEntry(name[0]))

info := decodeTxtRecord(entry.Info)
client.SetUuid(info["id"])
client.SetInfo(info)

select {
case d.found <- client:
Expand Down

0 comments on commit fce0e9f

Please sign in to comment.