Skip to content

Commit 6d4473e

Browse files
committed
Fixed no response if client can't get osu data from all of clients
1 parent c772480 commit 6d4473e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

get-info.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"time"
77
"log"
8+
"encoding/json"
89
// "sync"
910
)
1011

@@ -36,17 +37,23 @@ func getDataFromUrl(url string) ([]byte, error) {
3637

3738

3839
// TODO: Rewrite to use goroutines
39-
func getOsuData(urls []string) ([]byte, error) {
40-
var err error
40+
func getOsuData(urls []string) ([]byte) {
41+
var errors []string
4142
for _, url := range urls {
4243
data, err := getDataFromUrl(url)
4344
if err == nil {
44-
return data, nil
45+
return data
4546
} else {
4647
log.Print(err)
48+
errors = append(errors, err.Error())
4749
}
4850
}
49-
return nil, err
51+
errors_map := map[string]interface{}{}
52+
errors_map["error"] = errors
53+
errors_json, _ := json.Marshal(errors_map)
54+
55+
log.Print(string(errors_json))
56+
return errors_json
5057
}
5158

5259
// var wg sync.WaitGroup

receive-messages.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func CheckAuthResponse(message []byte) (error) {
4848
return nil
4949
}
5050

51+
// TODO: set default server Url here too
5152
func SetDefaultValuesToConfiguration(config *Config) {
5253
if config.StreamCompanionURL == "" {
5354
config.StreamCompanionURL = "http://localhost:20727/json"
@@ -72,7 +73,7 @@ func LoadConfiguration(file string) (Config, error) {
7273

7374
func handle_command(command string, urls []string) ([]byte, error) {
7475
if (command == "np") {
75-
return getOsuData(urls)
76+
return getOsuData(urls), nil
7677
}
7778
return nil, nil
7879
}

0 commit comments

Comments
 (0)