websockets-0.13.0.0: A sensible and clean way to write WebSocket-capable servers in Haskell.

Safe Haskell | None
Language | Haskell2010

Network.WebSockets.Connection.PingPong

Synopsis

- withPingPong :: PingPongOptions -> Connection -> (Connection -> IO ()) -> IO ()
- data PingPongOptions = PingPongOptions {
  - pingInterval :: Int
  - pongTimeout :: Int
  - pingAction :: IO ()
  }
- data PongTimeout = PongTimeout
- defaultPingPongOptions :: PingPongOptions

# Documentation

withPingPong :: PingPongOptions -> Connection -> (Connection -> IO ()) -> IO () Source #

Run an application with ping-pong enabled. Raises PongTimeout if a pong is not received.

Can used with Client and Server connections.

data PingPongOptions Source #

Options for ping-pong

Make sure that the ping interval is less than the pong timeout, for example N/2.

Constructors

PingPongOptions |

Fields

- pingInterval :: Int

  Interval in seconds

- pongTimeout :: Int

  Timeout in seconds

- pingAction :: IO ()

  Action to perform after sending a ping

data PongTimeout Source #

Exception type used to kill connections if there is a pong timeout.

Constructors

PongTimeout |

#### Instances

Instances details

Exception PongTimeout Source # |
Instance details Defined in Network.WebSockets.Connection.PingPong Methods toException :: PongTimeout -> SomeException Source # fromException :: SomeException -> Maybe PongTimeout Source # displayException :: PongTimeout -> String Source # backtraceDesired :: PongTimeout -> Bool Source #
Show PongTimeout Source # |
Instance details Defined in Network.WebSockets.Connection.PingPong Methods showsPrec :: Int -> PongTimeout -> ShowS Source # show :: PongTimeout -> String Source # showList :: [PongTimeout] -> ShowS Source #

defaultPingPongOptions :: PingPongOptions Source #

Default options for ping-pong

Ping every 15 seconds, timeout after 30 seconds