gore-and-ash-sync-1.1.0.0: Gore&Ash module for high level network synchronization

Copyright(c) Anton Gushcha, 2015-2016
LicenseBSD3
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Game.GoreAndAsh.Sync.Module

Description

 

Synopsis

Documentation

newtype SyncT s m a Source

Monad transformer of sync core module.

s
- State of next core module in modules chain;
m
- Next monad in modules monad stack;
a
- Type of result value;

How to embed module:

type AppStack = ModuleStack [LoggingT, NetworkT, ActorT, SyncT, ... other modules ... ] IO

-- | Current GHC (7.10.3) isn't able to derive this
instance SyncMonad AppMonad where 
  getSyncIdM = AppMonad . getSyncIdM
  getSyncTypeRepM = AppMonad . getSyncTypeRepM
  registerSyncIdM = AppMonad . registerSyncIdM
  addSyncTypeRepM a b = AppMonad $ addSyncTypeRepM a b
  syncScheduleMessageM peer ch i mt msg  = AppMonad $ syncScheduleMessageM peer ch i mt msg
  syncSetLoggingM = AppMonad . syncSetLoggingM
  syncSetRoleM = AppMonad . syncSetRoleM
  syncGetRoleM = AppMonad syncGetRoleM
  syncRequestIdM a b = AppMonad $ syncRequestIdM a b 

newtype AppMonad a = AppMonad (AppStack a)
  deriving (Functor, Applicative, Monad, MonadFix, MonadIO, LoggingMonad, MonadThrow, MonadCatch, NetworkMonad, ActorMonad)

The module is NOT pure within first phase (see ModuleStack docs), therefore currently only IO end monad can handler the module.

Constructors

SyncT 

Fields

runSyncT :: StateT (SyncState s) m a
 

registerSyncIdInternal :: HashableTypeRep -> SyncState s -> (Word64, SyncState s) Source

Internal implementation of actor registrarion when monadic context isn't in scope

addSyncTypeRepInternal :: HashableTypeRep -> Word64 -> SyncState s -> SyncState s Source

Internal implementation of actor registrarion when monadic context isn't in scope

syncRequestIdInternal :: forall proxy i m s. (ActorMonad m, NetworkMonad m, LoggingMonad m, NetworkMessage i) => Peer -> proxy i -> SyncState s -> m (SyncState s) Source

Internal implementation of sending service request for actor net id

getServiceChannel :: NetworkMonad m => m ChannelID Source

Return channel id 1 if network module has more than 1 channel, either fallback to 0

Note: If you open more than one channel, the module would use chanel id 1 as service channel, therefore count of channels on client and server should match (server won't response on channel 1 if it doesn't have it).

syncLog :: LoggingMonad m => SyncState s -> Text -> m () Source

Log only when flag is turned on