Skip to content

Commit 19f79e1

Browse files
authored
Remove Streaming API as it is currently broken. (#45)
1 parent f22e7b0 commit 19f79e1

File tree

4 files changed

+0
-189
lines changed

4 files changed

+0
-189
lines changed

client_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package tesla
22

33
import (
4-
"bytes"
54
"context"
65
"encoding/json"
76
"fmt"
@@ -100,15 +99,6 @@ func serveCheck(c func(req *http.Request, body []byte) error) http.HandlerFunc {
10099
}
101100
}
102101

103-
func serveStream(w http.ResponseWriter, req *http.Request) {
104-
w.WriteHeader(200)
105-
events := StreamEventString + "\n" +
106-
StreamEventString + "\n" +
107-
BadStreamEventString + "\n"
108-
b := bytes.NewBufferString(events)
109-
b.WriteTo(w)
110-
}
111-
112102
func init() {
113103
testMux.HandleFunc("/oauth/token", serveJSON("{\"access_token\": \"ghi789\"}"))
114104
testMux.HandleFunc("/api/1/vehicles", serveJSON(VehiclesJSON))
@@ -133,7 +123,6 @@ func init() {
133123
testMux.HandleFunc("/api/1/vehicles/1234/data_request/vehicle_state", serveJSON(VehicleStateJSON))
134124
testMux.HandleFunc("/api/1/vehicles/1234/mobile_enabled", serveJSON(TrueJSON))
135125
testMux.HandleFunc("/api/1/vehicles/1234/wake_up", serveJSON(WakeupResponseJSON))
136-
testMux.HandleFunc("/stream/", serveStream)
137126

138127
testMux.HandleFunc("/api/1/vehicles/1234/command/remote_start_drive", func(w http.ResponseWriter, req *http.Request) {
139128
if err := req.ParseForm(); err != nil {

examples/manage_car.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"encoding/json"
65
"fmt"
76
"os"
87

@@ -11,7 +10,6 @@ import (
1110

1211
func main() {
1312
ctx := context.Background()
14-
email := "[email protected]"
1513
client, err := tesla.NewClient(ctx, tesla.WithTokenFile("/file/path/to/token.json"))
1614
if err != nil {
1715
panic(err)
@@ -62,30 +60,4 @@ func main() {
6260
fmt.Println(vehicle.AutoparkForward())
6361
fmt.Println(vehicle.AutoparkReverse())
6462
// Take care with these, as the car will move
65-
66-
// Stream vehicle events
67-
eventChan, errChan, err := vehicle.Stream(email)
68-
if err != nil {
69-
fmt.Println(err)
70-
return
71-
}
72-
73-
for {
74-
select {
75-
case event := <-eventChan:
76-
eventJSON, _ := json.Marshal(event)
77-
fmt.Println(string(eventJSON))
78-
case err = <-errChan:
79-
fmt.Println(err)
80-
if err.Error() == "HTTP stream closed" {
81-
fmt.Println("Reconnecting!")
82-
eventChan, errChan, err = vehicle.Stream(email)
83-
if err != nil {
84-
fmt.Println(err)
85-
return
86-
}
87-
}
88-
}
89-
}
90-
9163
}

stream.go

Lines changed: 0 additions & 93 deletions
This file was deleted.

stream_test.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)