Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
class GetPacketId k pkt where Source #
getPacketId :: pkt -> k Source #
class SetPacketId k pkt where Source #
setPacketId :: k -> pkt -> pkt Source #
class SendPacket spkt where Source #
Nothing
sendPacket :: MonadIO m => spkt -> (ByteString -> m ()) -> m () Source #
default sendPacket :: (MonadIO m, Binary spkt) => spkt -> (ByteString -> m ()) -> m () Source #
class RecvPacket rpkt where Source #
recvPacket :: MonadIO m => (Int -> m ByteString) -> m rpkt Source #
class Servable serv where Source #
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 #
class Transport transport where Source #
data TransportConfig transport Source #
newTransport :: TransportConfig transport -> IO transport Source #
recvData :: transport -> Int -> IO ByteString Source #
sendData :: transport -> ByteString -> IO () Source #
closeTransport :: transport -> IO () Source #
Instances
Transport BSTransport Source # | |
Defined in Metro.TP.BS newTransport :: TransportConfig BSTransport -> IO BSTransport Source # recvData :: BSTransport -> Int -> IO ByteString Source # sendData :: BSTransport -> ByteString -> IO () Source # closeTransport :: BSTransport -> IO () Source # | |
Transport tp => Transport (Debug tp) Source # | |
Defined in Metro.TP.Debug data TransportConfig (Debug tp) Source # newTransport :: TransportConfig (Debug tp) -> IO (Debug tp) Source # recvData :: Debug tp -> Int -> IO ByteString Source # sendData :: Debug tp -> ByteString -> IO () Source # closeTransport :: Debug tp -> IO () Source # |
data TransportError Source #
Instances
Eq TransportError Source # | |
Defined in Metro.Class (==) :: TransportError -> TransportError -> Bool # (/=) :: TransportError -> TransportError -> Bool # | |
Ord TransportError Source # | |
Defined in Metro.Class compare :: TransportError -> TransportError -> Ordering # (<) :: TransportError -> TransportError -> Bool # (<=) :: TransportError -> TransportError -> Bool # (>) :: TransportError -> TransportError -> Bool # (>=) :: TransportError -> TransportError -> Bool # max :: TransportError -> TransportError -> TransportError # min :: TransportError -> TransportError -> TransportError # | |
Show TransportError Source # | |
Defined in Metro.Class showsPrec :: Int -> TransportError -> ShowS # show :: TransportError -> String # showList :: [TransportError] -> ShowS # | |
Exception TransportError Source # | |
Defined in Metro.Class |
sendBinary :: (MonadIO m, Binary spkt) => spkt -> (ByteString -> m ()) -> m () Source #
Instances
FromConn ConnT Source # | |
MonadTrans (ConnT tp) Source # | |
Defined in Metro.Conn | |
Monad m => MonadReader (ConnEnv tp) (ConnT tp m) Source # | |
Monad m => Monad (ConnT tp m) Source # | |
Functor m => Functor (ConnT tp m) Source # | |
Applicative m => Applicative (ConnT tp m) Source # | |
MonadIO m => MonadIO (ConnT tp m) Source # | |
Defined in Metro.Conn | |
MonadUnliftIO m => MonadUnliftIO (ConnT tp m) Source # | |
Defined in Metro.Conn |
initConnEnv :: (MonadIO m, Transport tp) => TransportConfig tp -> m (ConnEnv tp) Source #
data SessionT u nid k rpkt tp m a Source #
Instances
FromConn (SessionT u nid k rpkt) Source # | |
Monad m => MonadReader (SessionEnv u nid k rpkt) (SessionT u nid k rpkt tp m) Source # | |
Defined in Metro.Session ask :: SessionT u nid k rpkt tp m (SessionEnv u nid k rpkt) # local :: (SessionEnv u nid k rpkt -> SessionEnv u nid k rpkt) -> SessionT u nid k rpkt tp m a -> SessionT u nid k rpkt tp m a # reader :: (SessionEnv u nid k rpkt -> a) -> SessionT u nid k rpkt tp m a # | |
MonadTrans (SessionT u nid k rpkt tp) Source # | |
Defined in Metro.Session | |
Monad m => Monad (SessionT u nid k rpkt tp m) Source # | |
Functor m => Functor (SessionT u nid k rpkt tp m) Source # | |
Applicative m => Applicative (SessionT u nid k rpkt tp m) Source # | |
Defined in Metro.Session pure :: a -> SessionT u nid k rpkt tp m a # (<*>) :: SessionT u nid k rpkt tp m (a -> b) -> SessionT u nid k rpkt tp m a -> SessionT u nid k rpkt tp m b # liftA2 :: (a -> b -> c) -> SessionT u nid k rpkt tp m a -> SessionT u nid k rpkt tp m b -> SessionT u nid k rpkt tp m c # (*>) :: SessionT u nid k rpkt tp m a -> SessionT u nid k rpkt tp m b -> SessionT u nid k rpkt tp m b # (<*) :: SessionT u nid k rpkt tp m a -> SessionT u nid k rpkt tp m b -> SessionT u nid k rpkt tp m a # | |
MonadIO m => MonadIO (SessionT u nid k rpkt tp m) Source # | |
Defined in Metro.Session | |
MonadUnliftIO m => MonadUnliftIO (SessionT u nid k rpkt tp m) Source # | |
Defined in Metro.Session |
send :: (MonadUnliftIO m, Transport tp, SendPacket spkt, SetPacketId k spkt) => spkt -> SessionT u nid k rpkt tp m () Source #
makeResponse :: (MonadUnliftIO m, Transport tp, SendPacket spkt, SetPacketId k spkt) => (rpkt -> m (Maybe spkt)) -> SessionT u nid k rpkt tp m () Source #
makeResponse_ :: (MonadUnliftIO m, Transport tp, SendPacket spkt, SetPacketId k spkt) => (rpkt -> Maybe spkt) -> SessionT u nid k rpkt tp m () Source #
data NodeT u nid k rpkt tp m a Source #
Instances
FromConn (NodeT u nid k rpkt) Source # | |
Monad m => MonadReader (NodeEnv u nid k rpkt) (NodeT u nid k rpkt tp m) Source # | |
MonadTrans (NodeT u nid k rpkt tp) Source # | |
Defined in Metro.Node | |
Monad m => Monad (NodeT u nid k rpkt tp m) Source # | |
Functor m => Functor (NodeT u nid k rpkt tp m) Source # | |
Applicative m => Applicative (NodeT u nid k rpkt tp m) Source # | |
Defined in Metro.Node pure :: a -> NodeT u nid k rpkt tp m a # (<*>) :: NodeT u nid k rpkt tp m (a -> b) -> NodeT u nid k rpkt tp m a -> NodeT u nid k rpkt tp m b # liftA2 :: (a -> b -> c) -> NodeT u nid k rpkt tp m a -> NodeT u nid k rpkt tp m b -> NodeT u nid k rpkt tp m c # (*>) :: NodeT u nid k rpkt tp m a -> NodeT u nid k rpkt tp m b -> NodeT u nid k rpkt tp m b # (<*) :: NodeT u nid k rpkt tp m a -> NodeT u nid k rpkt tp m b -> NodeT u nid k rpkt tp m a # | |
MonadIO m => MonadIO (NodeT u nid k rpkt tp m) Source # | |
Defined in Metro.Node | |
MonadUnliftIO m => MonadUnliftIO (NodeT u nid k rpkt tp m) Source # | |
Defined in Metro.Node |
data SessionMode Source #
Instances
Eq SessionMode Source # | |
Defined in Metro.Node (==) :: SessionMode -> SessionMode -> Bool # (/=) :: SessionMode -> SessionMode -> Bool # | |
Show SessionMode Source # | |
Defined in Metro.Node showsPrec :: Int -> SessionMode -> ShowS # show :: SessionMode -> String # showList :: [SessionMode] -> ShowS # |
initEnv1 :: MonadIO m => (NodeEnv u nid k rpkt -> NodeEnv u nid k rpkt) -> ConnEnv tp -> u -> nid -> IO k -> m (NodeEnv1 u nid k rpkt tp) Source #
runSessionT_ :: Monad m => SessionEnv u nid k rpkt -> SessionT u nid k rpkt tp m a -> NodeT u nid k rpkt tp m a Source #
withSessionT :: (MonadUnliftIO m, Eq k, Hashable k) => Maybe Int64 -> SessionT u nid k rpkt tp m a -> NodeT u nid k rpkt tp m a Source #
newSessionEnv :: (MonadIO m, Eq k, Hashable k) => Maybe Int64 -> k -> NodeT u nid k rpkt tp m (SessionEnv u nid k rpkt) Source #
nextSessionId :: MonadIO m => NodeT u nid k rpkt tp m k Source #
startNodeT :: (MonadUnliftIO m, Transport tp, RecvPacket rpkt, GetPacketId k rpkt, Eq k, Hashable k) => SessionT u nid k rpkt tp m () -> NodeT u nid k rpkt tp m () Source #
startNodeT_ :: (MonadUnliftIO m, Transport tp, RecvPacket rpkt, GetPacketId k rpkt, Eq k, Hashable k) => (rpkt -> m Bool) -> SessionT u nid k rpkt tp m () -> NodeT u nid k rpkt tp m () Source #
request :: (MonadUnliftIO m, Transport tp, SendPacket spkt, SetPacketId k spkt, Eq k, Hashable k) => Maybe Int64 -> spkt -> NodeT u nid k rpkt tp m (Maybe rpkt) Source #
requestAndRetry :: (MonadUnliftIO m, Transport tp, SendPacket spkt, SetPacketId k spkt, Eq k, Hashable k) => Maybe Int64 -> Maybe Int -> spkt -> NodeT u nid k rpkt tp m (Maybe rpkt) Source #
data ServerT serv u nid k rpkt tp m a Source #
Instances
MonadTrans (ServerT serv u nid k rpkt tp) Source # | |
Defined in Metro.Server | |
Monad m => MonadReader (ServerEnv serv u nid k rpkt tp) (ServerT serv u nid k rpkt tp m) Source # | |
Defined in Metro.Server 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 # | |
Defined in Metro.Server | |
Functor m => Functor (ServerT serv u nid k rpkt tp m) Source # | |
Applicative m => Applicative (ServerT serv u nid k rpkt tp m) Source # | |
Defined in Metro.Server 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 # | |
Defined in Metro.Server | |
MonadUnliftIO m => MonadUnliftIO (ServerT serv u nid k rpkt tp m) Source # | |
Defined in Metro.Server |
data ServerEnv serv u nid k rpkt tp Source #
Instances
Monad m => MonadReader (ServerEnv serv u nid k rpkt tp) (ServerT serv u nid k rpkt tp m) Source # | |
Defined in Metro.Server 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 # |
runServerT :: ServerEnv serv u nid k rpkt tp -> ServerT serv u nid k rpkt tp m a -> m a 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 #
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 #
setServerName :: String -> ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp Source #
setDefaultSessionTimeout :: Int64 -> ServerEnv serv u nid k rpkt tp -> ServerEnv serv u nid k rpkt tp Source #
setOnNodeLeave :: MonadIO m => ServerEnv serv u nid k rpkt tp -> (nid -> u -> IO ()) -> 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 #
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 #