Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Streaming API as it is currently broken. #45

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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.