MCPcopy Create free account
hub / github.com/drosoCode/atvremote / readLoop

Method readLoop

pkg/v2/command/command.go:88–113  ·  view source on GitHub ↗

reading loop to read data from the android tv device

()

Source from the content-addressed store, hash-verified

86
87// reading loop to read data from the android tv device
88func (c *Command) readLoop() {
89 buffer := make([]byte, 512)
90 var total_data []byte
91 size_to_read := 0
92
93 for c.Read {
94
95 read_size, err := c.Connection.Read(buffer)
96 if err != nil {
97 c.Error = err
98 break
99 }
100
101 if size_to_read == 0 {
102 size_to_read = int(buffer[0])
103 if read_size > 1 {
104 // if there is more than 1 byte, the size is the first byte of the data
105 buffer = buffer[1:]
106 size_to_read = c.processData(read_size-1, size_to_read, &buffer, &total_data)
107 }
108 } else {
109 size_to_read = c.processData(read_size, size_to_read, &buffer, &total_data)
110 }
111
112 }
113}
114
115// send a remote message to the android tv device
116func (c *Command) write(data pb.RemoteMessage) error {

Callers 1

ConnectMethod · 0.95

Calls 1

processDataMethod · 0.95

Tested by

no test coverage detected