breaking change: Listen() now returns BasicResponse

This commit is contained in:
finn 2022-01-17 18:15:23 -08:00
parent dd56e3d6f7
commit e454d63249
2 changed files with 5 additions and 9 deletions

View file

@ -2,6 +2,7 @@ package client_protocol
import (
"encoding/json"
)
type BasicResponse struct {
@ -10,4 +11,5 @@ type BasicResponse struct {
ErrorType string
Error json.RawMessage
Data json.RawMessage
}
Account string
}

View file

@ -29,7 +29,6 @@ import (
"time"
client_protocol "gitlab.com/signald/signald-go/signald/client-protocol"
"gitlab.com/signald/signald-go/signald/client-protocol/v0"
)
const (
@ -101,7 +100,7 @@ func (s *Signald) connect() error {
}
// Listen listens for events from signald
func (s *Signald) Listen(c chan v0.LegacyResponse) {
func (s *Signald) Listen(c chan client_protocol.BasicResponse) {
for {
msg, err := s.readNext()
if err == io.EOF {
@ -127,12 +126,7 @@ func (s *Signald) Listen(c chan v0.LegacyResponse) {
}
if c != nil {
legacyResponse := v0.LegacyResponse{ID: msg.ID, Type: msg.Type}
if err := json.Unmarshal(msg.Data, &legacyResponse.Data); err != nil {
log.Println("signald-go receive error: ", err)
} else {
c <- legacyResponse
}
c <- msg
}
}
}