LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Server.ProtocolM

Contents

- The communication channels
- The server-client communication monad
- Protocol
- Assorted
- Internal operations

Description

The server definitions for the server-client communication protocol.

Synopsis

- type CliSerQueue = MVar
- type ConnServerDict = EnumMap FactionId ChanServer
- data ChanServer = ChanServer {
  - responseS :: CliSerQueue Response
  - requestAIS :: CliSerQueue RequestAI
  - requestUIS :: Maybe (CliSerQueue RequestUI)
  }
- class MonadServer m => MonadServerComm (m :: Type -> Type) where
  - getsDict :: (ConnServerDict -> a) -> m a
  - putDict :: ConnServerDict -> m ()
  - liftIO :: IO a -> m a
- sendUpdate :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> UpdAtomic -> m ()
- sendUpdateCheck :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> UpdAtomic -> m ()
- sendUpdNoState :: MonadServerComm m => FactionId -> UpdAtomic -> m ()
- sendSfx :: MonadServerComm m => FactionId -> SfxAtomic -> m ()
- sendQueryAI :: MonadServerComm m => FactionId -> ActorId -> m RequestAI
- sendQueryUI :: (MonadServerAtomic m, MonadServerComm m) => Response -> FactionId -> ActorId -> m RequestUI
- killAllClients :: (MonadServerAtomic m, MonadServerComm m) => m ()
- childrenServer :: MVar [Async ()]
- updateConn :: (MonadServerAtomic m, MonadServerComm m) => (FactionId -> ChanServer -> IO ()) -> m ()
- tryRestore :: MonadServerComm m => m (Maybe (State, StateServer))
- writeQueue :: MonadServerComm m => Response -> CliSerQueue Response -> m ()
- readQueueAI :: MonadServerComm m => CliSerQueue RequestAI -> m RequestAI
- readQueueUI :: MonadServerComm m => CliSerQueue RequestUI -> m RequestUI
- newQueue :: IO (CliSerQueue a)

# The communication channels

type CliSerQueue = MVar Source #

type ConnServerDict = EnumMap FactionId ChanServer Source #

Connection information for all factions, indexed by faction identifier.

data ChanServer Source #

Connection channel between the server and a single client.

Constructors

ChanServer |

Fields

- responseS :: CliSerQueue Response
- requestAIS :: CliSerQueue RequestAI
- requestUIS :: Maybe (CliSerQueue RequestUI)

# The server-client communication monad

class MonadServer m => MonadServerComm (m :: Type -> Type) where Source #

The server monad with the ability to communicate with clients.

Methods

getsDict :: (ConnServerDict -> a) -> m a Source #

putDict :: ConnServerDict -> m () Source #

liftIO :: IO a -> m a Source #

#### Instances

Instances details

MonadServerComm SerImplementation Source # |
Instance details Defined in Implementation.MonadServerImplementation Methods getsDict :: (ConnServerDict -> a) -> SerImplementation a Source # putDict :: ConnServerDict -> SerImplementation () Source # liftIO :: IO a -> SerImplementation a Source #

# Protocol

sendUpdate :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> UpdAtomic -> m () Source #

If the `AtomicFail` conditions hold, send a command to client, otherwise do nothing.

sendUpdateCheck :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> UpdAtomic -> m () Source #

Send a command to client, crashing if the `AtomicFail` conditions don't hold when executed on the client's state.

sendUpdNoState :: MonadServerComm m => FactionId -> UpdAtomic -> m () Source #

sendSfx :: MonadServerComm m => FactionId -> SfxAtomic -> m () Source #

sendQueryAI :: MonadServerComm m => FactionId -> ActorId -> m RequestAI Source #

sendQueryUI :: (MonadServerAtomic m, MonadServerComm m) => Response -> FactionId -> ActorId -> m RequestUI Source #

# Assorted

killAllClients :: (MonadServerAtomic m, MonadServerComm m) => m () Source #

childrenServer :: MVar [Async ()] Source #

updateConn :: (MonadServerAtomic m, MonadServerComm m) => (FactionId -> ChanServer -> IO ()) -> m () Source #

Update connections to the new definition of factions. Connect to clients in old or newly spawned threads that read and write directly to the channels.

tryRestore :: MonadServerComm m => m (Maybe (State, StateServer)) Source #

# Internal operations

writeQueue :: MonadServerComm m => Response -> CliSerQueue Response -> m () Source #

readQueueAI :: MonadServerComm m => CliSerQueue RequestAI -> m RequestAI Source #

readQueueUI :: MonadServerComm m => CliSerQueue RequestUI -> m RequestUI Source #

newQueue :: IO (CliSerQueue a) Source #