mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-05 18:46:21 +02:00
[#3054] added core.RealtimeConnectEvent.IdleTimeout field
This commit is contained in:
parent
b1093baef7
commit
06d3e27e03
@ -4,6 +4,8 @@
|
||||
to allow sending non-JSON body with the request ([#3058](https://github.com/pocketbase/pocketbase/discussions/3058)).
|
||||
The existing `data` prop will still work, but it will be recommended to use `body` instead (_to send JSON you can use `JSON.stringify(...)` as body value_).
|
||||
|
||||
- Added `core.RealtimeConnectEvent.IdleTimeout` field to allow specifying a different realtime idle timeout duration per client basis ([#3054](https://github.com/pocketbase/pocketbase/discussions/3054)).
|
||||
|
||||
|
||||
## v0.17.1
|
||||
|
||||
|
@ -66,6 +66,7 @@ func (api *realtimeApi) connect(c echo.Context) error {
|
||||
connectEvent := &core.RealtimeConnectEvent{
|
||||
HttpContext: c,
|
||||
Client: client,
|
||||
IdleTimeout: 5 * time.Minute,
|
||||
}
|
||||
|
||||
if err := api.app.OnRealtimeConnectRequest().Trigger(connectEvent); err != nil {
|
||||
@ -103,8 +104,8 @@ func (api *realtimeApi) connect(c echo.Context) error {
|
||||
}
|
||||
|
||||
// start an idle timer to keep track of inactive/forgotten connections
|
||||
idleDuration := 5 * time.Minute
|
||||
idleTimer := time.NewTimer(idleDuration)
|
||||
idleTimeout := connectEvent.IdleTimeout
|
||||
idleTimer := time.NewTimer(idleTimeout)
|
||||
defer idleTimer.Stop()
|
||||
|
||||
for {
|
||||
@ -143,7 +144,7 @@ func (api *realtimeApi) connect(c echo.Context) error {
|
||||
}
|
||||
|
||||
idleTimer.Stop()
|
||||
idleTimer.Reset(idleDuration)
|
||||
idleTimer.Reset(idleTimeout)
|
||||
case <-c.Request().Context().Done():
|
||||
// connection is closed
|
||||
if api.app.IsDebug() {
|
||||
|
@ -2,6 +2,7 @@ package core
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
@ -121,6 +122,7 @@ type MailerAdminEvent struct {
|
||||
type RealtimeConnectEvent struct {
|
||||
HttpContext echo.Context
|
||||
Client subscriptions.Client
|
||||
IdleTimeout time.Duration
|
||||
}
|
||||
|
||||
type RealtimeDisconnectEvent struct {
|
||||
|
6563
plugins/jsvm/internal/types/generated/types.d.ts
vendored
6563
plugins/jsvm/internal/types/generated/types.d.ts
vendored
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user