return body in handleUnexpectedClose
This commit is contained in:
parent
ccf95a1a21
commit
d622060355
|
@ -100,20 +100,20 @@ func newWebsocket(gamePk int32) (*gamedayWebsocket, <-chan error, error) {
|
||||||
return ws, ch, nil
|
return ws, ch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleUnexpectedClose(body []byte, client *api.APIClient) (*gamedayWebsocket, error) {
|
func handleUnexpectedClose(body []byte, client *api.APIClient) ([]byte, *gamedayWebsocket, error) {
|
||||||
ws, _, err := newWebsocket(gamePk)
|
ws, _, err := newWebsocket(gamePk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return body, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := client.GameAPI.LiveGameV1(context.Background(), gamePk)
|
req := client.GameAPI.LiveGameV1(context.Background(), gamePk)
|
||||||
resp, err := req.Execute()
|
resp, err := req.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ws, err
|
return body, ws, err
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = io.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
return ws, err
|
return body, ws, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateFeed(body []byte, ws *gamedayWebsocket, client *api.APIClient) ([]byte, error) {
|
func updateFeed(body []byte, ws *gamedayWebsocket, client *api.APIClient) ([]byte, error) {
|
||||||
|
@ -122,7 +122,7 @@ func updateFeed(body []byte, ws *gamedayWebsocket, client *api.APIClient) ([]byt
|
||||||
if websocket.IsUnexpectedCloseError(err, GameFinalCode, GameUnavailableCode) {
|
if websocket.IsUnexpectedCloseError(err, GameFinalCode, GameUnavailableCode) {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|
||||||
newWs, err := handleUnexpectedClose(body, client)
|
body, newWs, err := handleUnexpectedClose(body, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return body, err
|
return body, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue