metro-0.1.0.4: A simple tcp and udp socket server framework
Safe HaskellNone
LanguageHaskell2010

Metro.Server

Documentation

startServer :: (MonadUnliftIO m, Transport tp, Show nid, Eq nid, Hashable nid, Eq k, Hashable k, GetPacketId k rpkt, RecvPacket rpkt, Servable serv) => ServerEnv serv u nid k rpkt tp -> SessionT u nid k rpkt tp m () -> m () Source #

startServer_ :: (MonadUnliftIO m, Transport tp, Show nid, Eq nid, Hashable nid, Eq k, Hashable k, GetPacketId k rpkt, RecvPacket rpkt, Servable serv) => ServerEnv serv u nid k rpkt tp -> (rpkt -> m Bool) -> SessionT u nid k rpkt tp m () -> m () Source #

data ServerEnv serv u nid k rpkt tp Source #

Instances

Instances details
Monad m => MonadReader (ServerEnv serv u nid k rpkt tp) (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

ask :: ServerT serv u nid k rpkt tp m (ServerEnv serv u nid k rpkt tp) #

local :: (ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp) -> ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m a #

reader :: (ServerEnv serv u nid k rpkt tp -> a) -> ServerT serv u nid k rpkt tp m a #

data ServerT serv u nid k rpkt tp m a Source #

Instances

Instances details
MonadTrans (ServerT serv u nid k rpkt tp) Source # 
Instance details

Defined in Metro.Server

Methods

lift :: Monad m => m a -> ServerT serv u nid k rpkt tp m a #

Monad m => MonadReader (ServerEnv serv u nid k rpkt tp) (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

ask :: ServerT serv u nid k rpkt tp m (ServerEnv serv u nid k rpkt tp) #

local :: (ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp) -> ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m a #

reader :: (ServerEnv serv u nid k rpkt tp -> a) -> ServerT serv u nid k rpkt tp m a #

Monad m => Monad (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

(>>=) :: ServerT serv u nid k rpkt tp m a -> (a -> ServerT serv u nid k rpkt tp m b) -> ServerT serv u nid k rpkt tp m b #

(>>) :: ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m b -> ServerT serv u nid k rpkt tp m b #

return :: a -> ServerT serv u nid k rpkt tp m a #

Functor m => Functor (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

fmap :: (a -> b) -> ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m b #

(<$) :: a -> ServerT serv u nid k rpkt tp m b -> ServerT serv u nid k rpkt tp m a #

Applicative m => Applicative (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

pure :: a -> ServerT serv u nid k rpkt tp m a #

(<*>) :: ServerT serv u nid k rpkt tp m (a -> b) -> ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m b #

liftA2 :: (a -> b -> c) -> ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m b -> ServerT serv u nid k rpkt tp m c #

(*>) :: ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m b -> ServerT serv u nid k rpkt tp m b #

(<*) :: ServerT serv u nid k rpkt tp m a -> ServerT serv u nid k rpkt tp m b -> ServerT serv u nid k rpkt tp m a #

MonadIO m => MonadIO (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

liftIO :: IO a -> ServerT serv u nid k rpkt tp m a #

MonadUnliftIO m => MonadUnliftIO (ServerT serv u nid k rpkt tp m) Source # 
Instance details

Defined in Metro.Server

Methods

withRunInIO :: ((forall a. ServerT serv u nid k rpkt tp m a -> IO a) -> IO b) -> ServerT serv u nid k rpkt tp m b #

class Servable serv where Source #

Associated Types

data ServerConfig serv Source #

type SID serv Source #

type STP serv Source #

Methods

newServer :: MonadIO m => ServerConfig serv -> m serv Source #

servOnce :: MonadUnliftIO m => serv -> (Maybe (SID serv, TransportConfig (STP serv)) -> m ()) -> m () Source #

onConnEnter :: MonadIO m => serv -> SID serv -> m () Source #

onConnLeave :: MonadIO m => serv -> SID serv -> m () Source #

servClose :: MonadIO m => serv -> m () Source #

getNodeEnvList :: ServerEnv serv u nid k rpkt tp -> IOHashMap nid (NodeEnv1 u nid k rpkt tp) Source #

getServ :: ServerEnv serv u nid k rpkt tp -> serv Source #

serverEnv :: Monad m => ServerT serv u nid k rpkt tp m (ServerEnv serv u nid k rpkt tp) Source #

initServerEnv :: (MonadIO m, Servable serv) => ServerConfig serv -> IO k -> (TransportConfig (STP serv) -> TransportConfig tp) -> (SID serv -> ConnEnv tp -> IO (Maybe (nid, u))) -> m (ServerEnv serv u nid k rpkt tp) Source #

setServerName :: String -> ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp Source #

setNodeMode :: NodeMode -> ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp Source #

setSessionMode :: SessionMode -> ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp Source #

setDefaultSessionTimeout :: MonadIO m => ServerEnv serv u nid k rpkt tp -> Int -> m () Source #

setKeepalive :: MonadIO m => ServerEnv serv u nid k rpkt tp -> Int -> m () Source #

setOnNodeLeave :: MonadIO m => ServerEnv serv u nid k rpkt tp -> (nid -> u -> IO ()) -> m () Source #

runServerT :: ServerEnv serv u nid k rpkt tp -> ServerT serv u nid k rpkt tp m a -> m a Source #

stopServerT :: (MonadIO m, Servable serv) => ServerT serv u nid k rpkt tp m () Source #

handleConn :: (MonadUnliftIO m, Transport tp, Show nid, Eq nid, Hashable nid, Eq k, Hashable k, GetPacketId k rpkt, RecvPacket rpkt, Servable serv) => String -> SID serv -> ConnEnv tp -> nid -> u -> (rpkt -> m Bool) -> SessionT u nid k rpkt tp m () -> ServerT serv u nid k rpkt tp m (NodeEnv1 u nid k rpkt tp, Async ()) Source #