mirror of
https://github.com/hanzoai/go-openai-realtime.git
synced 2026-09-30 21:54:42 +00:00
feat: support ping for gorilla/websocket
This commit is contained in:
@@ -5,7 +5,7 @@ go 1.19
|
||||
// replace github.com/WqyJh/go-openai-realtime => ../../
|
||||
|
||||
require (
|
||||
github.com/WqyJh/go-openai-realtime v0.2.0-beta.2
|
||||
github.com/WqyJh/go-openai-realtime v0.3.5-0.20250208091501-af3079f3fb2b
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/stretchr/testify v1.9.0
|
||||
)
|
||||
@@ -14,6 +14,5 @@ require (
|
||||
github.com/coder/websocket v1.8.12 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/sashabaranov/go-openai v1.32.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
github.com/WqyJh/go-openai-realtime v0.2.0-beta.2 h1:4xD7O/IN5dQD2gKsiPzP1Prdu5HtCy25CChXep9kaIs=
|
||||
github.com/WqyJh/go-openai-realtime v0.2.0-beta.2/go.mod h1:nmUYODacQuObuh0DFSEIDfJM9L4ZFDRU/OEGYMryt60=
|
||||
github.com/WqyJh/go-openai-realtime v0.3.5-0.20250208091501-af3079f3fb2b h1:8teuz/JaWkMaqBrlIKF86EhHi0ajbJrm+shD1IXCvK8=
|
||||
github.com/WqyJh/go-openai-realtime v0.3.5-0.20250208091501-af3079f3fb2b/go.mod h1:nmUYODacQuObuh0DFSEIDfJM9L4ZFDRU/OEGYMryt60=
|
||||
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
||||
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -9,7 +9,6 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sashabaranov/go-openai v1.32.0 h1:Yk3iE9moX3RBXxrof3OBtUBrE7qZR0zF9ebsoO4zVzI=
|
||||
github.com/sashabaranov/go-openai v1.32.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
||||
@@ -118,3 +118,14 @@ func (c *WebSocketConn) Close() error {
|
||||
func (c *WebSocketConn) Response() *http.Response {
|
||||
return c.resp
|
||||
}
|
||||
|
||||
// Ping sends a ping message to the WebSocket connection.
|
||||
// It won't be blocked until the pong message is received.
|
||||
func (c *WebSocketConn) Ping(ctx context.Context) error {
|
||||
deadline, ok := ctx.Deadline()
|
||||
if ok {
|
||||
_ = c.conn.SetWriteDeadline(deadline)
|
||||
}
|
||||
|
||||
return c.conn.WriteControl(websocket.PingMessage, []byte{}, deadline)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user