License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | GHC2021 |
This module defines the core effects used for networking in the Minecraft protocol implementation. It provides bidirectional packet communication with compression and encryption support.
Synopsis
- data Talking (a :: Type -> Type) b where
- Hear :: forall b (a :: Type -> Type). (Unpack b, Typeable b) => Immediately -> Talking a b
- HearU :: forall (a :: Type -> Type). Immediately -> Talking a Uninterpreted
- HearA :: forall (a :: Type -> Type). Immediately -> Talking a SomeUnpack
- Say :: forall a1 (a :: Type -> Type). (Pack a1, Typeable a1) => a1 -> Talking a ()
- Setcompression :: forall (a :: Type -> Type). Int -> Talking a ()
- Setencryption :: forall (a :: Type -> Type). ByteString -> Talking a ()
- data Direction
- data Immediately
- data Op r where
- Parse :: Uninterpreted -> Op SomeUnpack
- Code :: Direction -> TypeRep -> Op (Maybe Word8)
- newtype ParserState = ParserState {
- send2parserstate :: forall r. Op r -> r
- type Talking' (es :: [Effect]) = (Talking :> es, State ParserState :> es, NonDet :> es)
- hear :: forall a (es :: [Effect]). (HasCallStack, Talking :> es, Unpack a, Typeable a) => Immediately -> Eff es a
- hearU :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => Immediately -> Eff es Uninterpreted
- hearA :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => Immediately -> Eff es SomeUnpack
- say :: forall a (es :: [Effect]). (HasCallStack, Talking :> es, Pack a, Typeable a) => a -> Eff es ()
- setcompression :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => Int -> Eff es ()
- setencryption :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => ByteString -> Eff es ()
- enter :: forall (es :: [Effect]). State ParserState :> es => ParserState -> Eff es ()
Core effect
data Talking (a :: Type -> Type) b where Source #
the communication effect
Hear :: forall b (a :: Type -> Type). (Unpack b, Typeable b) => Immediately -> Talking a b | listen for a message and assert its type when immediately is set and message missing, invoke |
HearU :: forall (a :: Type -> Type). Immediately -> Talking a Uninterpreted | listen for a raw uninterpreted message when immediately is set and message missing, invoke |
HearA :: forall (a :: Type -> Type). Immediately -> Talking a SomeUnpack | listen for a message with dynamic unpacking when immediately is set and message missing, invoke |
Say :: forall a1 (a :: Type -> Type). (Pack a1, Typeable a1) => a1 -> Talking a () | send a message |
Setcompression :: forall (a :: Type -> Type). Int -> Talking a () | set the compression threshold
|
Setencryption :: forall (a :: Type -> Type). ByteString -> Talking a () | set the encryption key |
Instances
type DispatchOf Talking Source # | |
Defined in M.IO.Internal.EffectTypes type DispatchOf Talking = 'Dynamic |
Types
relative packet direction. Used to identify packet flow without hardcoding client/server roles
Instances
data Immediately Source #
urgency level for receiving packets
Instances
operations on a packet
Parse :: Uninterpreted -> Op SomeUnpack | parse any packet |
Code :: Direction -> TypeRep -> Op (Maybe Word8) | find code of a packet based on its |
newtype ParserState Source #
parser state object (as in object-oriented programming)
ParserState | |
|
Effect operations
type Talking' (es :: [Effect]) = (Talking :> es, State ParserState :> es, NonDet :> es) Source #
the communication effect with parser state and non-determinism
hear :: forall a (es :: [Effect]). (HasCallStack, Talking :> es, Unpack a, Typeable a) => Immediately -> Eff es a Source #
listen for a message and assert its type
when immediately is set and message missing, invoke Empty
hearU :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => Immediately -> Eff es Uninterpreted Source #
listen for a raw uninterpreted message
when immediately is set and message missing, invoke Empty
hearA :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => Immediately -> Eff es SomeUnpack Source #
listen for a message with dynamic unpacking
when immediately is set and message missing, invoke Empty
say :: forall a (es :: [Effect]). (HasCallStack, Talking :> es, Pack a, Typeable a) => a -> Eff es () Source #
send a message
Configuration
setcompression :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => Int -> Eff es () Source #
set the compression threshold
- non-negative: compress messages larger than this size
- negative: disable compression
setencryption :: forall (es :: [Effect]). (HasCallStack, Talking :> es) => ByteString -> Eff es () Source #
set the encryption key
enter :: forall (es :: [Effect]). State ParserState :> es => ParserState -> Eff es () Source #
enter the parser state