feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
1 parent
aa6c3f50f4
commit
ceddfd3d6b
828 files changed
+122253
-13702
No files matched your search
@@ -2,7 +2,10 @@ package relay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/QuantumNous/new-api/pkg/wsmanager"
|
||||
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
||||
"github.com/QuantumNous/new-api/relaykit/dto"
|
||||
"github.com/QuantumNous/new-api/relaykit/types"
|
||||
@@ -33,6 +36,18 @@ func WssHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *types.
|
||||
if resp != nil {
|
||||
info.TargetWs = resp.(*websocket.Conn)
|
||||
defer info.TargetWs.Close()
|
||||
var closeOnce sync.Once
|
||||
unregister := wsmanager.Register(info.ChannelId, wsmanager.KindRealtime, func(reason string) {
|
||||
closeOnce.Do(func() {
|
||||
deadline := time.Now().Add(time.Second)
|
||||
closeMessage := websocket.FormatCloseMessage(websocket.ClosePolicyViolation, reason)
|
||||
_ = info.ClientWs.WriteControl(websocket.CloseMessage, closeMessage, deadline)
|
||||
_ = info.TargetWs.WriteControl(websocket.CloseMessage, closeMessage, deadline)
|
||||
_ = info.ClientWs.Close()
|
||||
_ = info.TargetWs.Close()
|
||||
})
|
||||
})
|
||||
defer unregister()
|
||||
}
|
||||
|
||||
usage, newAPIError := adaptor.DoResponse(c, nil, info)
|
||||
|
||||
Reference in new issue
Block a user