Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakurasan committed Oct 5, 2024
1 parent 2a0c18e commit 1afaf3b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/openai/realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@ func forwardMessages(ctx context.Context, src, dst *websocket.Conn) error {
case <-ctx.Done():
return ctx.Err()
default:
_, message, err := src.ReadMessage()
messageType, message, err := src.ReadMessage()
if err != nil {
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {
return nil // 正常关闭,不报错
}
return err
}
log.Println("Received message:", string(message))
err = dst.WriteMessage(websocket.TextMessage, message)
err = dst.WriteMessage(messageType, message)
if err != nil {
return err
}
Expand Down

0 comments on commit 1afaf3b

Please sign in to comment.