| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package streamclient | 5 package streamclient |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 client.Close() | 63 client.Close() |
| 64 } | 64 } |
| 65 }() | 65 }() |
| 66 | 66 |
| 67 data, err := json.Marshal(f) | 67 data, err := json.Marshal(f) |
| 68 if err != nil { | 68 if err != nil { |
| 69 return nil, fmt.Errorf("failed to marshal properties JSON: %s",
err) | 69 return nil, fmt.Errorf("failed to marshal properties JSON: %s",
err) |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Perform the handshake: magic + size(data) + data. | 72 // Perform the handshake: magic + size(data) + data. |
| 73 » s := &streamImpl{ | 73 » s := &BaseStream{ |
| 74 WriteCloser: client, | 74 WriteCloser: client, |
| 75 » » props: p, | 75 » » P: p, |
| 76 } | 76 } |
| 77 if _, err := s.writeRaw(streamproto.ProtocolFrameHeaderMagic); err != ni
l { | 77 if _, err := s.writeRaw(streamproto.ProtocolFrameHeaderMagic); err != ni
l { |
| 78 return nil, fmt.Errorf("failed to write magic number: %s", err) | 78 return nil, fmt.Errorf("failed to write magic number: %s", err) |
| 79 } | 79 } |
| 80 if err := s.writeRecord(data); err != nil { | 80 if err := s.writeRecord(data); err != nil { |
| 81 return nil, fmt.Errorf("failed to write properties: %s", err) | 81 return nil, fmt.Errorf("failed to write properties: %s", err) |
| 82 } | 82 } |
| 83 | 83 |
| 84 ownsClient = false // Passing ownership to caller. | 84 ownsClient = false // Passing ownership to caller. |
| 85 return s, nil | 85 return s, nil |
| 86 } | 86 } |
| OLD | NEW |