Skip to content

Commit

Permalink
Remove Streaming API as it is currently broken. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogosj committed Mar 22, 2021
1 parent f22e7b0 commit 19f79e1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 189 deletions.
11 changes: 0 additions & 11 deletions client_test.go
@@ -1,7 +1,6 @@
package tesla

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -100,15 +99,6 @@ func serveCheck(c func(req *http.Request, body []byte) error) http.HandlerFunc {
}
}

func serveStream(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(200)
events := StreamEventString + "\n" +
StreamEventString + "\n" +
BadStreamEventString + "\n"
b := bytes.NewBufferString(events)
b.WriteTo(w)
}

func init() {
testMux.HandleFunc("/oauth/token", serveJSON("{\"access_token\": \"ghi789\"}"))
testMux.HandleFunc("/api/1/vehicles", serveJSON(VehiclesJSON))
Expand All @@ -133,7 +123,6 @@ func init() {
testMux.HandleFunc("/api/1/vehicles/1234/data_request/vehicle_state", serveJSON(VehicleStateJSON))
testMux.HandleFunc("/api/1/vehicles/1234/mobile_enabled", serveJSON(TrueJSON))
testMux.HandleFunc("/api/1/vehicles/1234/wake_up", serveJSON(WakeupResponseJSON))
testMux.HandleFunc("/stream/", serveStream)

testMux.HandleFunc("/api/1/vehicles/1234/command/remote_start_drive", func(w http.ResponseWriter, req *http.Request) {
if err := req.ParseForm(); err != nil {
Expand Down
28 changes: 0 additions & 28 deletions examples/manage_car.go
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"encoding/json"
"fmt"
"os"

Expand All @@ -11,7 +10,6 @@ import (

func main() {
ctx := context.Background()
email := "email@example.com"
client, err := tesla.NewClient(ctx, tesla.WithTokenFile("/file/path/to/token.json"))
if err != nil {
panic(err)
Expand Down Expand Up @@ -62,30 +60,4 @@ func main() {
fmt.Println(vehicle.AutoparkForward())
fmt.Println(vehicle.AutoparkReverse())
// Take care with these, as the car will move

// Stream vehicle events
eventChan, errChan, err := vehicle.Stream(email)
if err != nil {
fmt.Println(err)
return
}

for {
select {
case event := <-eventChan:
eventJSON, _ := json.Marshal(event)
fmt.Println(string(eventJSON))
case err = <-errChan:
fmt.Println(err)
if err.Error() == "HTTP stream closed" {
fmt.Println("Reconnecting!")
eventChan, errChan, err = vehicle.Stream(email)
if err != nil {
fmt.Println(err)
return
}
}
}
}

}
93 changes: 0 additions & 93 deletions stream.go

This file was deleted.

57 changes: 0 additions & 57 deletions stream_test.go

This file was deleted.

0 comments on commit 19f79e1

Please sign in to comment.