postgres-websockets-0.6.0.0: Middleware to map LISTEN/NOTIFY messages to Websockets

Safe HaskellNone
LanguageHaskell2010

PostgresWebsockets.Broadcast

Contents

Description

PostgresWebsockets functions to broadcast messages to several listening clients This module provides a type called Multiplexer. The multiplexer contains a map of channels and a producer thread.

This module avoids any database implementation details, it is used by HasqlBroadcast where the database logic is combined.

Synopsis

Documentation

data Message Source #

Constructors

Message 
Instances
Eq Message Source # 
Instance details

Defined in PostgresWebsockets.Broadcast

Methods

(==) :: Message -> Message -> Bool #

(/=) :: Message -> Message -> Bool #

Show Message Source # 
Instance details

Defined in PostgresWebsockets.Broadcast

onMessage :: Multiplexer -> ByteString -> (Message -> IO ()) -> IO () Source #

Adds a listener to a certain multiplexer's channel. The listener must be a function that takes a 'TChan Message' and perform any IO action. All listeners run in their own thread. The first listener will open the channel, when a listener dies it will check if there acquire any others and close the channel when that's the case.

relayMessages :: Multiplexer -> IO () Source #

Reads the messages from the producer and relays them to the active listeners in their respective channels.

relayMessagesForever :: Multiplexer -> IO ThreadId Source #

Opens a thread that relays messages from the producer thread to the channels forever

Re-exports

readTQueue :: TQueue a -> STM a #

Read the next value from the TQueue.

writeTQueue :: TQueue a -> a -> STM () #

Write a value to a TQueue.

readTChan :: TChan a -> STM a #

Read the next value from the TChan.