This commit is contained in:
2025-05-27 16:22:36 +02:00
parent 38a1d5a2c6
commit ecf5fb46a0
11 changed files with 246 additions and 57 deletions

View File

@ -364,7 +364,7 @@ func (o *Operations) Version(ctx context.Context) (string, bool, error) {
return strings.TrimSpace(res.Version), res.Stable, nil
}
func (o *Operations) AveragePosition(ctx context.Context) error {
func (o *Operations) AveragePosition(ctx context.Context) (*protocol.TaskMessage, error) {
var err error
go func() {
@ -373,10 +373,27 @@ func (o *Operations) AveragePosition(ctx context.Context) error {
}()
if err = o.client.Emit("task", map[string]string{"name": "average_base_coordinates"}); err != nil {
return err
return nil, err
}
ch, err := o.On(ctx, "task_status")
for message := range ch {
// Convertir vers notre struct
jsonData, err := json.Marshal(message)
if err != nil {
continue
}
var taskMsg protocol.TaskMessage
if err := json.Unmarshal(jsonData, &taskMsg); err != nil {
continue
}
if taskMsg.State == "completed" {
return &taskMsg, nil
}
}
return err
return nil, err
}
// TODO À VOIR POUR LES VERSION 1