module IHP.AutoRefresh.Types where
import IHP.Prelude
import IHP.Controller.RequestContext
import Control.Concurrent.MVar (MVar)
import qualified IHP.PGListener as PGListener
data AutoRefreshState = AutoRefreshDisabled | AutoRefreshEnabled { AutoRefreshState -> UUID
sessionId :: !UUID }
data AutoRefreshSession = AutoRefreshSession
{ AutoRefreshSession -> UUID
id :: !UUID
, AutoRefreshSession -> RequestContext -> IO ()
renderView :: !(RequestContext -> IO ())
, AutoRefreshSession -> MVar ()
event :: !(MVar ())
, AutoRefreshSession -> Set ByteString
tables :: !(Set ByteString)
, AutoRefreshSession -> LByteString
lastResponse :: !LByteString
, AutoRefreshSession -> UTCTime
lastPing :: !UTCTime
}
data AutoRefreshServer = AutoRefreshServer
{ AutoRefreshServer -> [Subscription]
subscriptions :: [PGListener.Subscription]
, AutoRefreshServer -> [AutoRefreshSession]
sessions :: ![AutoRefreshSession]
, AutoRefreshServer -> Set ByteString
subscribedTables :: !(Set ByteString)
, AutoRefreshServer -> PGListener
pgListener :: PGListener.PGListener
}
newAutoRefreshServer :: PGListener.PGListener -> AutoRefreshServer
newAutoRefreshServer :: PGListener -> AutoRefreshServer
newAutoRefreshServer PGListener
pgListener = AutoRefreshServer { subscriptions :: [Subscription]
subscriptions = [], sessions :: [AutoRefreshSession]
sessions = [], subscribedTables :: Set ByteString
subscribedTables = Set ByteString
forall a. Monoid a => a
mempty, PGListener
pgListener :: PGListener
pgListener :: PGListener
pgListener }